lib/chanko/invoker.rb in chanko-2.0.5 vs lib/chanko/invoker.rb in chanko-2.0.6

- old
+ new

@@ -38,20 +38,32 @@ else super end end + def __current_run_default_depth + @__run_default_depth ||= 0 + end + + def __increment_run_default_depth + @__run_default_depth = __current_run_default_depth + 1 + end + + def __decrement_run_default_depth + @__run_default_depth = __current_run_default_depth - 1 + end + def __find_unit_local(method_name) __current_unit_locals.has_key?(method_name) end def __fetch_unit_local(method_name) __current_unit_locals[method_name] end def __current_unit_locals - __unit_locals_stack.last || {} + __unit_locals_stack[-1 - __current_run_default_depth] || {} end def __unit_locals_stack @__unit_locals_stack ||= [] end @@ -71,21 +83,27 @@ def __defaults_stack @__defaults_stack ||= [] end def __default_block - __defaults_stack.last + __defaults_stack[-1 - __current_run_default_depth] end def __has_default_block? !!__default_block end def __invoke_default_block - if view? - capture(&__default_block) - else - instance_exec(&__default_block) + current_default_block = __default_block + begin + __increment_run_default_depth + if view? + capture(&current_default_block) + else + instance_exec(&current_default_block) + end + ensure + __decrement_run_default_depth end end def __with_default_stack(default) __defaults_stack << default