Class: Ergane::DSL::BlockDSL

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

Instance Method Summary collapse

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