Class: Patm::Rule::Compiled

Inherits:
Object
  • Object
show all
Defined in:
lib/patm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src_body, context) ⇒ Compiled

Returns a new instance of Compiled.



514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/patm.rb', line 514

def initialize(src_body, context)
  @src_body = src_body
  @context = context
  @src = <<-RUBY
  def apply(_obj, _self = nil)
    _ctx = @context
    _match = {}
#{@src_body}
  end
  RUBY

  singleton_class = class <<self; self; end
  singleton_class.class_eval(@src)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



530
531
532
# File 'lib/patm.rb', line 530

def context
  @context
end

#src_bodyObject (readonly)

Returns the value of attribute src_body.



529
530
531
# File 'lib/patm.rb', line 529

def src_body
  @src_body
end