Class: ModSpox::Models::Config

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/mod_spox/models/Config.rb

Overview

Attributes provided by model:

name

name of the config item

value

value of the config item

It is important to note this model is for storing configuration values only. It will only store strings, not complex objects. If you need to store an object, use the Setting model. TODO: find and remove any [] usage

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set(sym, value) ⇒ Object



23
24
25
26
27
# File 'lib/mod_spox/models/Config.rb', line 23

def Config.set(sym, value)
    s = Config.find_or_create(:name => "#{sym}")
    s.value = value
    s.save
end

.val(sym) ⇒ Object



18
19
20
21
# File 'lib/mod_spox/models/Config.rb', line 18

def Config.val(sym)
    s = Config.filter(:name => "#{sym}").first
    return s ? s.value : nil
end

Instance Method Details

#name=(config_name) ⇒ Object



13
14
15
16
# File 'lib/mod_spox/models/Config.rb', line 13

def name=(config_name)
    config_name.downcase!
    super(config_name)
end