Sha256: 3ceecef97186f869ca0f761e36186a268435e66f0fffffb5aa338a27aef8d80d
Contents?: true
Size: 556 Bytes
Versions: 3
Compression:
Stored size: 556 Bytes
Contents
class UserPreferences::Preference < ActiveRecord::Base self.table_name = 'preferences' belongs_to :user validates_uniqueness_of :name, scope: [:user_id, :category] validates_presence_of :user_id, :category, :name validates :value, inclusion: { in: ->(p) { p.permitted_values }} delegate :binary?, :default, :permitted_values, :lookup, :to_db, to: :definition def update_value!(v) update_attributes!(value: to_db(v)) end def value lookup(attributes['value']) end def definition UserPreferences[category, name] end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
user_preferences-0.0.3 | lib/user_preferences/preference.rb |
user_preferences-0.0.2 | lib/user_preferences/preference.rb |
user_preferences-0.0.1 | lib/user_preferences/preference.rb |