Class: RailsSettings::SettingObject
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RailsSettings::SettingObject
show all
- Defined in:
- lib/rails-settings/setting_object.rb
Constant Summary
collapse
- REGEX_SETTER =
/\A([a-z]\w*)=\Z/i
- REGEX_GETTER =
/\A([a-z]\w*)\Z/i
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rails-settings/setting_object.rb', line 35
def method_missing(method_name, *args, &block)
if block_given?
super
else
if attribute_names.include?(method_name.to_s.sub('=', ''))
super
elsif method_name.to_s =~ REGEX_SETTER && args.size == 1
_set_value($1, args.first)
elsif method_name.to_s =~ REGEX_GETTER && args.size == 0
_get_value($1)
else
super
end
end
end
|
Instance Method Details
#respond_to?(method_name, include_priv = false) ⇒ Boolean
31
32
33
|
# File 'lib/rails-settings/setting_object.rb', line 31
def respond_to?(method_name, include_priv = false)
super || method_name.to_s =~ REGEX_SETTER || _setting?(method_name)
end
|