Module: Authpds::ActsAsAuthentic::CoreAttributes

Defined in:
lib/authpds/acts_as_authentic/core_attributes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
# File 'lib/authpds/acts_as_authentic/core_attributes.rb', line 4

def self.included(klass)
  klass.class_eval do
    serialize :user_attributes
  end
end

Instance Method Details

#user_attributes=(new_attributes) ⇒ Object

“Smart” updating of user_attributes. Maintains user_attributes that are not explicity overwritten.



17
18
19
20
21
# File 'lib/authpds/acts_as_authentic/core_attributes.rb', line 17

def user_attributes=(new_attributes)
  write_attribute(:user_attributes, new_attributes) and return unless new_attributes.kind_of?(Hash)
  # Set new/updated attributes
  write_attribute(:user_attributes, (user_attributes || {}).merge(new_attributes))
end

#username=(value) ⇒ Object

Setting the username field also resets the persistence_token if the value changes.



11
12
13
14
# File 'lib/authpds/acts_as_authentic/core_attributes.rb', line 11

def username=(value)
  write_attribute(:username, value)
  reset_persistence_token if username_changed?
end