Sha256: 4bf4585d02fd842b9a712e8cd48a4462170ac906d9d648cadf1f3d0884c98c9a

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 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 != "objectClass"
          attribute_will_change!(name) unless value == get_attribute(name)
        end
        super
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeldap-3.2.1 lib/active_ldap/attribute_methods/dirty.rb
activeldap-3.2.0 lib/active_ldap/attribute_methods/dirty.rb