Class: Dsl

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

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Dsl

Returns a new instance of Dsl.



2
3
4
5
6
7
8
9
# File 'lib/dsl.rb', line 2

def initialize(*args, &block)
  if block_given?
    @_original_self = block.binding.eval("self")
    instance_eval(&block)
    remove_instance_variable :@_original_self
  end
  finish_init if defined? :finish_init
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



11
12
13
14
15
# File 'lib/dsl.rb', line 11

def method_missing(name, *args, &block)
  return Petri.send(name) if Petri.respond_to?(name)
  
  @_original_self ? @_original_self.send(name, *args, &block) : super
end