Class: GrowlGlue::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
# File 'lib/growl_glue/config.rb', line 6

def initialize
  @options={}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



19
20
21
# File 'lib/growl_glue/config.rb', line 19

def method_missing(name, *args, &block)
  self.set_options(name, *args)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/growl_glue/config.rb', line 4

def options
  @options
end

Instance Method Details

#option(*keys) ⇒ Object

returns a nested option value



11
12
13
14
15
16
17
# File 'lib/growl_glue/config.rb', line 11

def option(*keys)
  option = @options
  until keys.empty? or option.nil?
    option = option[keys.shift]
  end
  option
end

#set_options(key, opts) ⇒ Object



23
24
25
26
# File 'lib/growl_glue/config.rb', line 23

def set_options(key, opts)
  @options[key] ||= {}
  @options[key].merge!(opts)
end