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



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

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

Instance Method Details

#instance(&block) ⇒ Object



7
8
9
10
11
# File 'lib/simpleton.rb', line 7

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