Method: Challah::UserProvideable#providers

Defined in:
lib/challah/concerns/user/provideable.rb

#providersObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/challah/concerns/user/provideable.rb', line 22

def providers
  return @providers if @providers

  @providers = {}

  attributes = self.class.authorization_model.hashable_attributes

  # Grab providers from existing authorization records
  @providers = authorizations.inject({}) do |hash, m|
    hash[m.provider.to_sym] = attributes.inject({}) { |p, a| p[a.to_sym] = m.send(a); p }
    hash
  end

  # Then, grab any provider attributes provided
  provider_attributes.each do |k, v|
    if v.respond_to?(:fetch)
      @providers[k] = v
    end
  end

  @providers
end