Module: OmniAuth::Identity::Models::Sequel

Defined in:
lib/omniauth/identity/models/sequel.rb

Overview

sequel.jeremyevans.net/ an SQL ORM NOTE: Sequel is not based on ActiveModel, but supports the API we need, except for ‘persisted?`:

  • create

  • save

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/omniauth/identity/models/sequel.rb', line 13

def self.included(base)
  base.class_eval do
    # NOTE: Using the deprecated :validations_class_methods because it defines
    #       validates_confirmation_of, while current :validation_helpers does not.
    # plugin :validation_helpers
    plugin :validation_class_methods

    include ::OmniAuth::Identity::Model
    include ::OmniAuth::Identity::SecurePassword

    has_secure_password

    alias_method :persisted?, :valid?

    def self.auth_key=(key)
      super
      validates_uniqueness_of :key, case_sensitive: false
    end

    def self.locate(search_hash)
      where(search_hash).first
    end

    def persisted?
      exists?
    end

    def save
      super
    end
  end
end