Sha256: fcfbe1faa462de180417a64ccb924bb47721ec61db76a0d67862a93dd3dff64c

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

# The execution scope for running matches. Built dynamically for each match by mixing in modules and setting variables.
# @api private

class ActionTree::EvalScope

  # Build a new EvalScope from the given sources. The
  # sources can be:
  #
  # * Hash: instance variable names and values (:name becomes @name)
  # * Module: will be extended
  # * Array: flattened and used just the same
  #
  def initialize(*sources)
    Array(sources).flatten.each do |s|
      case s
      when Hash
        s.each {|k,v| instance_variable_set(:"@#{k}", v) }
      when Module then extend s
      else
        raise 'invalid scope source ' + s.inspect
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action_tree-0.2.0 lib/action_tree/eval_scope.rb