Sha256: 3dcc54a3c667fa264157be6341996425a03be4b89b6720c3a6df31ab3ba1c6a4

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

#
module ActiveLdap
  module AttributeMethods
    module Dirty
      extend ActiveSupport::Concern
      include ActiveModel::Dirty

      # Attempts to +save+ the record and clears changed attributes if successful.
      def save(*) #:nodoc:
        succeeded = super
        if succeeded
          @previously_changed = changes
          @changed_attributes.clear
        end
        succeeded
      end

      # Attempts to <tt>save!</tt> the record and clears changed attributes if successful.
      def save!(*) #:nodoc:
        super.tap do
          @previously_changed = changes
          @changed_attributes.clear
        end
      end

      # <tt>reload</tt> the record and clears changed attributes.
      def reload(*) #:nodoc:
        super.tap do
          @previously_changed.clear
          @changed_attributes.clear
        end
      end

    protected
      def set_attribute(name, value)
        if name and name != "objectClass"
          attribute_will_change!(name) unless value == get_attribute(name)
        end
        super
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
activeldap-5.1.1 lib/active_ldap/attribute_methods/dirty.rb
activeldap-5.1.0 lib/active_ldap/attribute_methods/dirty.rb
activeldap-3.2.3 lib/active_ldap/attribute_methods/dirty.rb
powerhome-activeldap-3.2.3 lib/active_ldap/attribute_methods/dirty.rb
activeldap-4.0.6 lib/active_ldap/attribute_methods/dirty.rb
activeldap-4.0.5 lib/active_ldap/attribute_methods/dirty.rb
activeldap-4.0.4 lib/active_ldap/attribute_methods/dirty.rb
activeldap-4.0.3 lib/active_ldap/attribute_methods/dirty.rb
activeldap-4.0.2 lib/active_ldap/attribute_methods/dirty.rb
activeldap-4.0.1 lib/active_ldap/attribute_methods/dirty.rb
activeldap-4.0.0 lib/active_ldap/attribute_methods/dirty.rb
activeldap-3.2.2 lib/active_ldap/attribute_methods/dirty.rb