1
0
Fork 0
mirror of https://github.com/ms-ati/docile synced 2023-03-27 23:21:52 -04:00

Update README.md

This commit is contained in:
Marc Siegel 2018-01-16 14:47:46 -05:00 committed by GitHub
parent 1317045c10
commit b66d9b0bf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,7 +48,7 @@ def with_array(arr=[], &block)
end
```
**Easy!**
Easy!
### Wait! Can't I do that with just `instance_eval` or `instance_exec`?
@ -59,7 +59,7 @@ In short: **No**.
Not if you want the code in the block to be able to refer to anything
the block would normally have access to from the surrounding context.
Let's be very specific. Docile internally uses `instance_exec` (see [execution.rb#25](lib/docile/execution.rb#L25)), adding a small layer to support referencing *local variables*, *instance variables*, and *methods* from the _block's context_ **or** the target _object's context_, interchangeably. This is "the **hard part**", where most folks making a DSL in Ruby throw up their hands.
Let's be very specific. Docile internally uses `instance_exec` (see [execution.rb#25](lib/docile/execution.rb#L25)), adding a small layer to support referencing *local variables*, *instance variables*, and *methods* from the _block's context_ **or** the target _object's context_, interchangeably. This is "**the hard part**", where most folks making a DSL in Ruby throw up their hands.
For example: