25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/copies_omniauth.rb', line 25
def copies_omniauth(args={})
options = self.class_variable_set( :@@copies_omniauth_options,
{ :overwrite => true,
:provider_name => self.name.sub("Profile","").downcase,
:secret_attribute => :secret,
:skip_provider_check => false,
:token_attribute => :token,
:uid_attribute => :uid
})
unless args[:options].nil?
options.merge!(args[:options])
end
attributes = self.class_variable_set( :@@copies_omniauth_attributes,
{ options[:secret_attribute] => SECRET_KEY,
options[:token_attribute] => TOKEN_KEY,
options[:uid_attribute] => UID_KEY
})
unless args[:attributes].nil?
attributes.merge!(args[:attributes])
end
[ options[:secret_attribute],
options[:token_attribute],
options[:uid_attribute] ].each do |attr|
attributes.delete(attr) unless instance_has_setter_for?(attr)
end
attributes.each do |attr,omniauth_key|
case omniauth_key
when Array, String, Symbol
else
raise ArgumentError, "Don't know how to traverse OmniAuth with #{omniauth_key}"
end
end
include CopiesOmniauth::InstanceMethods
end
|