Module: Mongoid::Xoauth::ClassMethods

Defined in:
lib/mongoid/xoauth.rb

Instance Method Summary collapse

Instance Method Details

#find_by_oauth(oauth) ⇒ Object



19
20
21
# File 'lib/mongoid/xoauth.rb', line 19

def find_by_oauth(oauth)
  where('oauths.uid' => oauth.uid, 'oauths._type' => oauth.class.to_s).first
end

#xoauth(params) ⇒ Object

weibo_web/mobile: secret, callback, qq: secret



12
13
14
15
16
17
# File 'lib/mongoid/xoauth.rb', line 12

def xoauth(params) # weibo_web/mobile: {appid, secret, callback}, qq: {key, secret}
  raise "invalid coauth params #{params.to_s}" unless params.is_a?(Hash)
  embeds_many :oauths, class_name: 'Oauth::Provider', as: :oauthable
  # config oauths
  params.each_pair{|key, param| Oauth::Configure[key.to_s] = param}
end