Class: SettingCrazy::Inheritor
- Inherits:
-
Object
- Object
- SettingCrazy::Inheritor
- Defined in:
- lib/settingcrazy/inheritor.rb
Instance Method Summary collapse
-
#initialize(via, options = {}) ⇒ Inheritor
constructor
A new instance of Inheritor.
-
#parent_settings_for(model) ⇒ Object
Returns the appropriate parent settings.
Constructor Details
#initialize(via, options = {}) ⇒ Inheritor
Returns a new instance of Inheritor.
4 5 6 7 8 |
# File 'lib/settingcrazy/inheritor.rb', line 4 def initialize(via, = {}) # TODO: Do a reflection look up to make sure its valid @via = via @parent_namespace = [:namespace] end |
Instance Method Details
#parent_settings_for(model) ⇒ Object
Returns the appropriate parent settings
11 12 13 14 15 16 17 18 19 |
# File 'lib/settingcrazy/inheritor.rb', line 11 def parent_settings_for(model) return nil if model.send(@via).blank? association = model.send(@via) if pn = parent_namespace(model) association.settings.send(pn) else association.settings end end |