Class: Ergane::DSL::BlockDSL
Instance Method Summary collapse
-
#initialize(command_class) ⇒ BlockDSL
constructor
A new instance of BlockDSL.
- #run(&block) ⇒ Object
Constructor Details
#initialize(command_class) ⇒ BlockDSL
Returns a new instance of BlockDSL.
6 7 8 |
# File 'lib/ergane/dsl/block_dsl.rb', line 6 def initialize(command_class) @command_class = command_class end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **opts, &block) ⇒ Object (private)
20 21 22 23 24 25 26 |
# File 'lib/ergane/dsl/block_dsl.rb', line 20 def method_missing(name, *args, **opts, &block) if @command_class.respond_to?(name) @command_class.public_send(name, *args, **opts, &block) else super end end |
Instance Method Details
#run(&block) ⇒ Object
10 11 12 |
# File 'lib/ergane/dsl/block_dsl.rb', line 10 def run(&block) @command_class.define_method(:run) { |*args| instance_exec(*args, &block) } end |