Class: Dsl
- Inherits:
-
Object
- Object
- Dsl
- Defined in:
- lib/dsl.rb
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Dsl
constructor
A new instance of Dsl.
- #method_missing(name, *args, &block) ⇒ Object
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 |