Class: EasySettings
Defined Under Namespace
Classes: SourceFileNotExist
Constant Summary
collapse
- DEFAULT_FILES =
%w(settings.yml config/settings.yml)
EasySettingsVersion::VERSION
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &blk) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/easy_settings.rb', line 77
def method_missing(method_name, *args, &blk)
return self.[](method_name, &blk) if key?(method_name)
name, suffix = method_suffix(method_name)
case suffix
when '='
assign_property(name, args.first)
when '?'
!!self[name]
when '!'
initializing_reader(name)
when '_'
underbang_reader(name)
else
if !args[0].nil? or (args[1] and args[1][:nil])
assign_property(name, args.first)
else
self[method_name]
end
end
end
|
Class Attribute Details
.namespace ⇒ Object
Returns the value of attribute namespace.
15
16
17
|
# File 'lib/easy_settings.rb', line 15
def namespace
@namespace
end
|
.source_file ⇒ Object
Returns the value of attribute source_file.
15
16
17
|
# File 'lib/easy_settings.rb', line 15
def source_file
@source_file
end
|
.source_hash ⇒ Object
Returns the value of attribute source_hash.
15
16
17
|
# File 'lib/easy_settings.rb', line 15
def source_hash
@source_hash
end
|
Class Method Details
.[](key) ⇒ Object
31
32
33
|
# File 'lib/easy_settings.rb', line 31
def [](key)
instance[key]
end
|
.[]=(key, val) ⇒ Object
35
36
37
|
# File 'lib/easy_settings.rb', line 35
def []=(key, val)
instance[key] = val
end
|
.instance ⇒ Object
17
18
19
|
# File 'lib/easy_settings.rb', line 17
def instance
@instance ||= new(namespace ? _source[namespace] : _source)
end
|
.load! ⇒ Object
21
22
23
24
|
# File 'lib/easy_settings.rb', line 21
def load!
instance
true
end
|
.reload! ⇒ Object
26
27
28
29
|
# File 'lib/easy_settings.rb', line 26
def reload!
@instance = nil
load!
end
|
Instance Method Details
#assign_property(name, value) ⇒ Object
72
73
74
75
|
# File 'lib/easy_settings.rb', line 72
def assign_property(name, value)
super
self[name]
end
|