Class: HasSettings::Setting

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/has_settings/setting.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listObject



21
22
23
# File 'lib/has_settings/setting.rb', line 21

def self.list
  @settings.keys
end

.protected?(key) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/has_settings/setting.rb', line 29

def self.protected?(key)
  @settings[key]
end

.setting(key, options = nil) ⇒ Object



16
17
18
19
# File 'lib/has_settings/setting.rb', line 16

def self.setting(key, options = nil)
  @settings ||= {}
  @settings[key] = options && options[:protected]
end

.table_nameObject



25
26
27
# File 'lib/has_settings/setting.rb', line 25

def self.table_name
  name.tableize
end

Instance Method Details

#createObject



9
10
11
12
13
14
# File 'lib/has_settings/setting.rb', line 9

def create
  if new_record?
    super
  end
  self
end

#protected?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/has_settings/setting.rb', line 33

def protected?
  self.class.protected?(self.name.to_sym)
end