Sha256: 4f65d10867ce6fbc69b998d0e46c63682506920719c3959b05a21e46a33cba7b

Contents?: true

Size: 819 Bytes

Versions: 13

Compression:

Stored size: 819 Bytes

Contents

module Authpds
  module ActsAsAuthentic
    module CoreAttributes
      def self.included(klass)
        klass.class_eval do
          serialize :user_attributes
        end
      end

      # Setting the username field also resets the persistence_token if the value changes.
      def username=(value)
        write_attribute(:username, value)
        reset_persistence_token if username_changed?
      end

      # "Smart" updating of user_attributes.  Maintains user_attributes that are not explicity overwritten.
      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
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
authpds-1.1.2 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-1.1.1 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-1.1.0 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-1.0.0 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.9 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.8 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.7 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.6 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.5 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.4 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.3 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.2 lib/authpds/acts_as_authentic/core_attributes.rb
authpds-0.2.1 lib/authpds/acts_as_authentic/core_attributes.rb