Module: Passport::Oauth::Record::ClassMethods

Defined in:
lib/passport/oauth/protocol/record.rb

Instance Method Summary collapse

Instance Method Details

#find_or_create_tokenObject

this gives you the final key and secret that we will store in the database



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/passport/oauth/protocol/record.rb', line 11

def find_or_create_token
  hash = token_class.access(
    :token          => request_token,
    :secret         => request_secret,
    :oauth_verifier => verifier,
    :callback_url   => callback_url
  )
  if token.respond_to?(:find_by_key_or_token)
    token = token_class.find_by_key_or_token(hash[:key], hash[:token])
  end
  token ||= token_class.new(hash)
  token
end

#restore(record) ⇒ Object

restore attributes



32
33
34
# File 'lib/passport/oauth/protocol/record.rb', line 32

def restore(record)
  record.attributes = session.delete(:auth_attributes) if record.respond_to?(:attributes)
end

#store(record) ⇒ Object



25
26
27
28
29
# File 'lib/passport/oauth/protocol/record.rb', line 25

def store(record)
  session[:auth_attributes] = record.attributes.reject! do |k, v|
    v.blank? || !record.respond_to?(k)
  end if record.respond_to?(:attributes)
end