lib/bauxite/core/context.rb in bauxite-0.6.7 vs lib/bauxite/core/context.rb in bauxite-0.6.8
- old
+ new
@@ -708,18 +708,30 @@
# # => {"a"=>"1", "b"=>"2", "c"=>"a"}
#
def with_vars(vars)
current = @variables
@variables = @variables.merge(vars)
- yield
+ ret_vars = nil
+
+ ret = yield
+
+ returned = @variables['__RETURN__']
+ if returned == ['*']
+ ret_vars = @variables.clone
+ ret_vars.delete '__RETURN__'
+ elsif returned != nil
+ ret_vars = @variables.select { |k,v| returned.include? k }
+ end
rescue StandardError => e
e.instance_variable_set "@variables", @variables
def e.variables
@variables
end
raise
ensure
@variables = current
+ @variables.merge!(ret_vars) if ret_vars
+ ret
end
private
def self._action_methods
(Action.public_instance_methods(false) \
\ No newline at end of file