Class: UrbanizzoSettings::Config

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/urbanizzo_settings/config.rb

Class Method Summary collapse

Class Method Details

.[](*keys) ⇒ Object

This method returns the values of the config simulating a Hash, like:

Configuration[:foo]

It can also bring Arrays of keys, like:

Configuration[:foo, :bar]

… so you can pass it to a method using *. It is memoized, so it will be correctly cached.



13
14
15
16
17
18
19
# File 'app/models/urbanizzo_settings/config.rb', line 13

def [] *keys
  if keys.size == 1
    get keys.shift
  else
    keys.map{|key| get key }
  end
end

.[]=(key, value) ⇒ Object



20
21
22
# File 'app/models/urbanizzo_settings/config.rb', line 20

def []= key, value
  set key, value
end

.get_without_cache(key) ⇒ Object



24
25
26
# File 'app/models/urbanizzo_settings/config.rb', line 24

def get_without_cache(key)
  find_by_name(key).value rescue nil
end