Class: Transproc::Transformer::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/transproc/transformer/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#astObject (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

#containerObject (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

#dupObject

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