Module: User::Identities::OauthBuildCreateAndFind

Included in:
OAuth
Defined in:
app/models/user/identities/o_auth.rb

Overview

The class methods have been moved into a separate module so that they could be added as association extensions if necessary.

Instance Method Summary collapse

Instance Method Details

#build_identity(sign_up) ⇒ Object



12
13
14
15
16
17
# File 'app/models/user/identities/o_auth.rb', line 12

def build_identity 
  identity = initialize_from_omniauth([:oauth_data])
  ..oauth_identities << identity

  identity
end

#find_from_omniauth(ominauth_data) ⇒ Object



24
25
26
27
# File 'app/models/user/identities/o_auth.rb', line 24

def find_from_omniauth ominauth_data
  identity_provider = provider_from_ominauth(ominauth_data)
  identity_provider.find_by(uid: ominauth_data[:uid])
end

#find_identity(sign_in) ⇒ Object



8
9
10
# File 'app/models/user/identities/o_auth.rb', line 8

def find_identity 
  find_from_omniauth([:oauth_data])
end

#find_or_build_from_omniauth(ominauth_data) ⇒ Object



29
30
31
# File 'app/models/user/identities/o_auth.rb', line 29

def find_or_build_from_omniauth ominauth_data
  find_from_omniauth(ominauth_data) || initialize_from_omniauth(ominauth_data)
end

#initialize_from_omniauth(ominauth_data) ⇒ Object



19
20
21
22
# File 'app/models/user/identities/o_auth.rb', line 19

def initialize_from_omniauth ominauth_data
  identity_provider = provider_from_ominauth(ominauth_data)
  identity_provider.new(ominauth_data: ominauth_data)
end