Class: Configurable

Inherits:
Object
  • Object
show all
Defined in:
lib/configurable.rb

Instance Method Summary collapse

Constructor Details

#initializeConfigurable



2
3
4
# File 'lib/configurable.rb', line 2

def initialize
  @stuff = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



6
7
8
9
10
11
12
13
14
# File 'lib/configurable.rb', line 6

def method_missing(name, *args, &block)
  if name.to_s =~ /=$/
    @stuff[name.to_s.sub(/=$/, '')] = args.first
    return
  end

  return @stuff[name] if @stuff[name]
  @stuff[name] = Configurable.new
end

Instance Method Details

#nil?Boolean



16
17
18
# File 'lib/configurable.rb', line 16

def nil?
  true
end