Module: Simpleton::ClassMethods

Defined in:
lib/simpleton.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



18
19
20
# File 'lib/simpleton.rb', line 18

def method_missing(method, *args, &block)
  instance.respond_to?(method) ? instance.send(method, *args, &block) : super
end

Instance Method Details

#instance(&block) ⇒ Object



12
13
14
15
16
# File 'lib/simpleton.rb', line 12

def instance(&block)
  @instance ||= new
  block.call(@instance) if block_given?
  @instance
end