Module: Choosy::DSL::BaseBuilder

Included in:
ArgumentBuilder, BaseCommandBuilder
Defined in:
lib/choosy/dsl/base_builder.rb

Overview

Must have entity attribute

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



16
17
18
19
20
21
22
# File 'lib/choosy/dsl/base_builder.rb', line 16

def method_missing(method, *args, &block)
  if @self_before_instance_eval
    @self_before_instance_eval.send(method, *args, &block)
  else
    raise NoMethodError.new("undefined method '#{method}' for #{self.class.name}")
  end
end

Instance Method Details

#evaluate!(&block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/choosy/dsl/base_builder.rb', line 5

def evaluate!(&block)
  if block_given?
    @self_before_instance_eval = eval "self", block.binding
    instance_eval(&block)
  end
  @self_before_instance_eval = nil

  entity.finalize!
  entity
end