Module: CASClient::UserAPI::ClassMethods
- Defined in:
- lib/cas_client/user_api.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/cas_client/user_api.rb', line 66
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^find_or_create_facebook_user_by_(.*)$/
find_or_create_facebook_user($1, arguments.first)
else
super
end
end
|
Instance Method Details
#cas_all ⇒ Object
24
25
26
27
|
# File 'lib/cas_client/user_api.rb', line 24
def cas_all
res = fetch("#{::CAS_SERVER["internal_cas_domain"]}/api/users")
Yajl::Parser.new(:symbolize_keys => true).parse(res.body)
end
|
#cas_fetch_user(uuid) ⇒ Object
29
30
31
32
33
|
# File 'lib/cas_client/user_api.rb', line 29
def cas_fetch_user(uuid)
res = fetch("#{::CAS_SERVER["internal_cas_domain"]}/api/users/#{CGI.escape(uuid)}")
Yajl::Parser.new(:symbolize_keys => true).parse(res.body)
rescue CASClient::UUIDNotFound
end
|
#cas_uuid_available?(uuid) ⇒ Boolean
35
36
37
|
# File 'lib/cas_client/user_api.rb', line 35
def cas_uuid_available?(uuid)
!cas_fetch_user(uuid)
end
|
#find_or_create_facebook_user(attribute, auth) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/cas_client/user_api.rb', line 14
def find_or_create_facebook_user(attribute, auth)
if auth['provider'] == 'facebook_signup'
attributes = {}
cas_map.invert.each_pair do |k,v|
attributes.store(k.to_sym, auth['extra'][v.to_s]) unless attribute.to_sym == k.to_sym
end
send(("find_or_create_by_" + attribute), auth['extra'][cas_map.invert[attribute.to_sym].to_s], attributes)
end
end
|