Class: Smartdown::Parser::NodeTransform

Inherits:
Parslet::Transform
  • Object
show all
Defined in:
lib/smartdown/parser/node_transform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_module = nil, &block) ⇒ NodeTransform

Returns a new instance of NodeTransform.



34
35
36
37
38
# File 'lib/smartdown/parser/node_transform.rb', line 34

def initialize data_module=nil, &block
  super(&block)

  @data_module = data_module || {}
end

Instance Attribute Details

#data_moduleObject (readonly)

Returns the value of attribute data_module.



32
33
34
# File 'lib/smartdown/parser/node_transform.rb', line 32

def data_module
  @data_module
end

Instance Method Details

#call_on_match(bindings, block) ⇒ Object

TODO: Horrible monkey patching, should try to submit a PR to parselet to allow modification of bindings?



42
43
44
45
# File 'lib/smartdown/parser/node_transform.rb', line 42

def call_on_match(bindings, block)
  bindings.merge! data_module
  super(bindings, block)
end