Class: Transproc::Transformer::DSL
- Inherits:
-
Object
- Object
- Transproc::Transformer::DSL
- Defined in:
- lib/transproc/transformer/dsl.rb
Instance Attribute Summary collapse
- #ast ⇒ Object readonly private
- #container ⇒ Object readonly private
Instance Method Summary collapse
- #call(transformer) ⇒ Object private
- #dup ⇒ Object private
-
#initialize(container, ast: [], &block) ⇒ DSL
constructor
private
A new instance of DSL.
Constructor Details
#initialize(container, ast: [], &block) ⇒ DSL
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DSL.
16 17 18 19 20 |
# File 'lib/transproc/transformer/dsl.rb', line 16 def initialize(container, ast: [], &block) @container = container @ast = ast instance_eval(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 |
# File 'lib/transproc/transformer/dsl.rb', line 45 def method_missing(meth, *args, &block) arg_nodes = *args.map { |a| [:arg, a] } ast << [:fn, (block ? [meth, [*arg_nodes, node(&block)]] : [meth, arg_nodes])] end |
Instance Attribute Details
#ast ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/transproc/transformer/dsl.rb', line 13 def ast @ast end |
#container ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/transproc/transformer/dsl.rb', line 10 def container @container end |
Instance Method Details
#call(transformer) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/transproc/transformer/dsl.rb', line 28 def call(transformer) Compiler.new(container, transformer).(ast) end |
#dup ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/transproc/transformer/dsl.rb', line 23 def dup self.class.new(container, ast: ast.dup) end |