Class: SettingCrazy::Inheritor

Inherits:
Object
  • Object
show all
Defined in:
lib/settingcrazy/inheritor.rb

Instance Method Summary collapse

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, options = {})
  # TODO: Do a reflection look up to make sure its valid
  @via              = via
  @parent_namespace = options[: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