Sha256: bbba726f419380b9e3f51a0b2ea28e1343c19ae5fc018b8e7f15b364ba6e3870
Contents?: true
Size: 711 Bytes
Versions: 4
Compression:
Stored size: 711 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 # class Parslet::Transform::Context < BlankSlate reveal :methods reveal :respond_to? reveal :inspect reveal :to_s reveal :instance_variable_set 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
4 entries across 4 versions & 2 rubygems