Module: OmniAuth::Identity::Models::DataMapper

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

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/omniauth/identity/models/data_mapper.rb', line 8

def self.included(base)
  base.class_eval do
    include OmniAuth::Identity::Model
    include OmniAuth::Identity::SecurePassword

    # http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-persisted-3F
    # http://rubydoc.info/github/mongoid/mongoid/master/Mongoid/State#persisted%3F-instance_method
    alias persisted? valid?

    has_secure_password

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

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