Class: Setting
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Setting
- Defined in:
- app/models/setting.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exists?(keyname) ⇒ Boolean
20 21 22 |
# File 'app/models/setting.rb', line 20 def self.exists?(keyname) (Setting.find( :first, :select => '`id`', :conditions => [ 'keyname = ?', keyname.to_s] )) ? true : false end |
.grab(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/setting.rb', line 8 def self.grab(*args) map = HashWithIndifferentAccess.new Setting.find( :all, :select => '`keyname`, `keyval`', :conditions => ['keyname IN (?)', args.collect(&:to_s)] ).each { |s| map[s.keyname] = s.keyval } args.collect {|a| (map.key? a) ? map[a] : nil } end |
.set!(keyname, value) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/setting.rb', line 24 def self.set!(keyname,value) setting = Setting.find(:first, :conditions => [ 'keyname = ?', keyname.to_s ] ) raise StandardError unless setting setting.keyval = value.to_s setting.save! setting.keyval end |
Instance Method Details
#authorized_for?(options) ⇒ Boolean
35 36 37 38 39 |
# File 'app/models/setting.rb', line 35 def () return true unless .try(:[],:action) ([:action].to_sym != :delete) end |