Class: Omnigollum::Models::OmniauthUser

Inherits:
User
  • Object
show all
Defined in:
lib/omnigollum.rb

Instance Attribute Summary

Attributes inherited from User

#email, #name, #provider, #uid

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ OmniauthUser

Returns a new instance of OmniauthUser.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/omnigollum.rb', line 16

def initialize (hash)
  # Validity checks, don't trust providers 
  @uid = hash['uid']
  raise OmniauthUserInitError, "Invalid data from provider, 'uid' must not be empty or whitespace" if @uid.to_s.strip.empty?
    
  @name = hash['info']['name'].to_s.strip
  raise OmniauthUserInitError, "Invalid data from provider, 'info => name' must not be empty or whitespace" if @name.empty?
    
  @email    = hash['info']['email'].to_s.strip if hash['info'].has_key?('email')
  @provider = hash['provider']
  self
end