Module: HasSettings

Defined in:
lib/has_settings.rb,
lib/has_settings/setting.rb,
lib/has_settings/active_record_extension.rb

Defined Under Namespace

Modules: ActiveRecordExtension Classes: Setting

Class Method Summary collapse

Class Method Details

.ensure_settings_class(owner_class) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/has_settings.rb', line 6

def self.ensure_settings_class(owner_class)
  const_name = "#{owner_class.name}Setting".to_sym
  unless Object.const_defined?(const_name)
    settings_class = Object.const_set(const_name, Class.new(HasSettings::Setting))
    settings_class.owner_class = owner_class
  end
  Object.const_get(const_name)
end