Class: Dry::Transformer::Pipe::DSL
- Inherits:
-
Object
- Object
- Dry::Transformer::Pipe::DSL
- Defined in:
- lib/dry/transformer/pipe/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.
- #t(name, *args) ⇒ Object
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.
17 18 19 20 21 |
# File 'lib/dry/transformer/pipe/dsl.rb', line 17 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.
51 52 53 54 |
# File 'lib/dry/transformer/pipe/dsl.rb', line 51 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.
14 15 16 |
# File 'lib/dry/transformer/pipe/dsl.rb', line 14 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.
11 12 13 |
# File 'lib/dry/transformer/pipe/dsl.rb', line 11 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.
34 35 36 |
# File 'lib/dry/transformer/pipe/dsl.rb', line 34 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.
29 30 31 |
# File 'lib/dry/transformer/pipe/dsl.rb', line 29 def dup self.class.new(container, ast: ast.dup) end |
#t(name, *args) ⇒ Object
24 25 26 |
# File 'lib/dry/transformer/pipe/dsl.rb', line 24 def t(name, *args) container[name, *args] end |