Class: Mobox::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/mobox/config.rb
Instance Method Summary
collapse
Constructor Details
#initialize(file) ⇒ Config
Returns a new instance of Config.
7
8
9
|
# File 'lib/mobox/config.rb', line 7
def initialize(file)
@attributes = YAML.load(File.open( file ).read)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/mobox/config.rb', line 19
def method_missing name, *args, &block
if @attributes.has_key? name.to_s
@attributes[name.to_s]
else
super
end
end
|
Instance Method Details
#[](attr_name) ⇒ Object
11
12
13
|
# File 'lib/mobox/config.rb', line 11
def [] attr_name
@attributes[attr_name.to_s]
end
|
#[]=(attr_name, value) ⇒ Object
15
16
17
|
# File 'lib/mobox/config.rb', line 15
def []= attr_name, value
@attributes[attr_name.to_s] = value
end
|
#respond_to?(name) ⇒ Boolean
27
28
29
|
# File 'lib/mobox/config.rb', line 27
def respond_to? name
@attributes.has_key?(name.to_s) or super
end
|
#to_json ⇒ Object
31
32
33
|
# File 'lib/mobox/config.rb', line 31
def to_json
@attributes.to_json
end
|