Module: Preferable::Model::PreferableMethods

Defined in:
lib/preferable/model.rb

Instance Method Summary collapse

Instance Method Details

#preferencesObject

Accessor to preferences. Examples:

user = User.find(1)
user.preferences[:theme_id] # => 8
user.preferences[:theme_id] = 3


42
43
44
# File 'lib/preferable/model.rb', line 42

def preferences
  @preferences ||= Preferable::Set.wrap(self, super)
end

#preferences=(hash) ⇒ Object

Preferences writer. Updates existing preferences (doesn’t replace them!)



47
48
49
50
# File 'lib/preferable/model.rb', line 47

def preferences=(hash)
  preferences.set(hash) if hash.is_a?(Hash)
  preferences
end