Class: Manioc::Container::DSL

Inherits:
BasicObject
Defined in:
lib/manioc/container.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ DSL

Returns a new instance of DSL.



6
7
8
9
# File 'lib/manioc/container.rb', line 6

def initialize &block
  @fields = {}
  instance_exec(&block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
18
# File 'lib/manioc/container.rb', line 15

def method_missing name, *args, &block
  return super if args.any?
  @fields[name] = block
end

Instance Method Details

#to_hObject



11
12
13
# File 'lib/manioc/container.rb', line 11

def to_h
  @fields
end