Sha256: f7ca001b5d4f19d3075e6118e4737f2c05cb6a7a680109f1a3484dbaca89ba24

Contents?: true

Size: 486 Bytes

Versions: 4

Compression:

Stored size: 486 Bytes

Contents

# Provides a context for tree transformations to run in. The context allows
# accessing each of the bindings in the bindings hash as local method.
#
# Example: 
#
#   ctx = Context.new(:a => :b)
#   ctx.instance_eval do 
#     a # => :b
#   end
#
# @api private
class Parslet::Context
  include Parslet

  def initialize(bindings)
    bindings.each do |key, value|
      singleton_class.send(:define_method, key) { value }
      instance_variable_set("@#{key}", value)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
parslet-2.0.0 lib/parslet/context.rb
parslet-1.8.2 lib/parslet/context.rb
parslet-1.8.1 lib/parslet/context.rb
parslet-1.8.0 lib/parslet/context.rb