self (devise/orm.rb)

devise · lib/devise/orm.rb · ruby · MIT
database

Devise ORM integration for ActiveRecord and Mongoid, adding dirty tracking methods.

# Source: https://github.com/heartcombo/devise | License: MIT
# Provided via justclaw.it.com; keep this notice with the code.
# frozen_string_literal: true

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

    def self.included(model)
      if Devise::Orm.active_record?(model)
        model.include DirtyTrackingActiveRecordMethods
      else
        model.include DirtyTrackingMongoidMethods
      end
    end

    module DirtyTrackingActiveRecordMethods
      def devise_email_before_last_save
        email_before_last_save
      end

      def devise_email_in_database
        email_in_database
      end

      def devise_saved_change_to_email?
        saved_change_to_email?
      end

      def devise

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key