Module: Eco::Language::Methods::DslAble

Included in:
API::Session::Batch::BasePolicy, API::Session::Batch::Job, API::UseCases::BaseIO
Defined in:
lib/eco/language/methods/dsl_able.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, **kargs, &block) ⇒ Object

When it's the case, redirect to the original evaluate caller



18
19
20
21
# File 'lib/eco/language/methods/dsl_able.rb', line 18

def method_missing(method, *args, **kargs, &block)
  super unless @self_before_evaluate
  @self_before_evaluate.send(method, *args, **kargs, &block)
end

Instance Method Details

#evaluate(*args, **kargs, &block) ⇒ Object

Note:

if the object misses any method, redirects the method to the original evaluate caller.

It runs the block within this object context



8
9
10
11
12
13
14
# File 'lib/eco/language/methods/dsl_able.rb', line 8

def evaluate(*args, **kargs, &block)
  return unless block_given?
  @self_before_evaluate = eval('self', block.binding, __FILE__, __LINE__)
  instance_exec(*args, **kargs, &block).tap do
    @self_before_evaluate = nil
  end
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Note:

that for a Dsl this is not necessary

This allows to capture a method using name method.

Returns:

  • (Boolean)


25
26
27
# File 'lib/eco/language/methods/dsl_able.rb', line 25

def respond_to_missing?(name, include_private = false)
  super
end