Module: Authpds::ActsAsAuthentic::CoreAttributes
- Defined in:
- lib/authpds/acts_as_authentic/core_attributes.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#user_attributes=(new_attributes) ⇒ Object
“Smart” updating of user_attributes.
-
#username=(value) ⇒ Object
Setting the username field also resets the persistence_token if the value changes.
Class Method Details
.included(klass) ⇒ Object
4 5 6 |
# File 'lib/authpds/acts_as_authentic/core_attributes.rb', line 4 def self.included(klass) klass.class_eval { serialize :user_attributes } end |
Instance Method Details
#user_attributes=(new_attributes) ⇒ Object
“Smart” updating of user_attributes. Maintains user_attributes that are not explicity overwritten.
16 17 18 19 20 21 22 23 24 |
# File 'lib/authpds/acts_as_authentic/core_attributes.rb', line 16 def user_attributes=(new_attributes) if new_attributes.kind_of?(Hash) # Merge new/updated attributes with new attributes taking precedence merged_attributes = (user_attributes || {}).merge(new_attributes) write_attribute(:user_attributes, merged_attributes) else write_attribute(:user_attributes, new_attributes) end end |
#username=(value) ⇒ Object
Setting the username field also resets the persistence_token if the value changes.
9 10 11 12 |
# File 'lib/authpds/acts_as_authentic/core_attributes.rb', line 9 def username=(value) write_attribute(:username, value) reset_persistence_token if username_changed? end |