Sha256: 061e6aee5b0e47ce88113d42ddc875dbf428c13a251f4bf7df89b649b5b55887

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

module Kingsman
  module Orm # :nodoc:
    def self.active_record?(model)
      defined?(ActiveRecord) && model < ActiveRecord::Base
    end

    def self.included(model)
      model.include DirtyTrackingMethods
    end

    module DirtyTrackingMethods
      def kingsman_email_before_last_save
        email_before_last_save
      end

      def kingsman_email_in_database
        email_in_database
      end

      def kingsman_saved_change_to_email?
        saved_change_to_email?
      end

      def kingsman_saved_change_to_encrypted_password?
        saved_change_to_encrypted_password?
      end

      def kingsman_will_save_change_to_email?
        will_save_change_to_email?
      end

      def kingsman_respond_to_and_will_save_change_to_attribute?(attribute)
        respond_to?("will_save_change_to_#{attribute}?") && send("will_save_change_to_#{attribute}?")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kingsman-0.1.1 lib/kingsman/orm.rb
kingsman-0.1.0 lib/kingsman/orm.rb