Sha256: 81432447310b00df028a13487f89c275bf0add0cc078bab8ccabcd2214ea12db

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

# The scope in which matched actions are run. Used to copy instance variables, define instance variables from captures, and extend helper method modules.

class ActionTree::EvalScope
  def initialize(*ingredients)
    ingredients.each do |ing|
      case ing
        when Hash
          ing.each do |name, value|
            instance_variable_set(:"@#{name}", value)
          end
        when Module
          extend ing
        else
          ing.instance_variables.each do |name|
            self.instance_variable_set(name,
              ing.instance_variable_get(name)
              )
          end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
action_tree-0.1.1 lib/action_tree/eval_scope.rb
action_tree-0.1.0 lib/action_tree/eval_scope.rb