mirror of
https://github.com/ms-ati/docile
synced 2023-03-27 23:21:52 -04:00
Docile.dsl_eval can pass arguments to the block.
This commit breaks ruby 1.8 compatibility.
This commit is contained in:
parent
1ad260d3b0
commit
7839870c52
2 changed files with 4 additions and 4 deletions
|
@ -17,12 +17,12 @@ module Docile
|
|||
# @param dsl [Object] an object whose methods represent a DSL
|
||||
# @param block [Proc] a block to execute in the DSL context
|
||||
# @return [Object] the dsl object, after execution of the block
|
||||
def dsl_eval(dsl, &block)
|
||||
def dsl_eval(dsl, *args, &block)
|
||||
block_context = eval("self", block.binding)
|
||||
proxy_context = FallbackContextProxy.new(dsl, block_context)
|
||||
begin
|
||||
block_context.instance_variables.each { |ivar| proxy_context.instance_variable_set(ivar, block_context.instance_variable_get(ivar)) }
|
||||
proxy_context.instance_eval(&block)
|
||||
proxy_context.instance_exec(*args,&block)
|
||||
ensure
|
||||
block_context.instance_variables.each { |ivar| block_context.instance_variable_set(ivar, proxy_context.instance_variable_get(ivar)) }
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'set'
|
|||
|
||||
module Docile
|
||||
class FallbackContextProxy
|
||||
NON_PROXIED_METHODS = Set[:object_id, :__send__, :__id__, :==, :equal?, :"!", :"!=", :instance_eval,
|
||||
NON_PROXIED_METHODS = Set[:object_id, :__send__, :__id__, :==, :equal?, :"!", :"!=", :instance_exec,
|
||||
:instance_variables, :instance_variable_get, :instance_variable_set,
|
||||
:remove_instance_variable]
|
||||
|
||||
|
@ -50,4 +50,4 @@ module Docile
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue