Sha256: 5a46b5273f69579610481572e1f341ded4ef3ef1611e63fb7af8427a36873c5f
Contents?: true
Size: 734 Bytes
Versions: 3
Compression:
Stored size: 734 Bytes
Contents
require 'blankslate' # 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 < BlankSlate reveal :methods reveal :respond_to? reveal :inspect reveal :to_s reveal :instance_variable_set include Parslet def meta_def(name, &body) metaclass = class <<self; self; end metaclass.send(:define_method, name, &body) end def initialize(bindings) bindings.each do |key, value| meta_def(key.to_sym) { value } instance_variable_set("@#{key}", value) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
parslet-1.7.0 | lib/parslet/context.rb |
parslet-1.6.2 | lib/parslet/context.rb |
parslet-1.6.1 | lib/parslet/context.rb |