Class: HoninClient::Identity

Inherits:
Object
  • Object
show all
Defined in:
lib/honin/client/identity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(claims) ⇒ Identity

Returns a new instance of Identity.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/honin/client/identity.rb', line 8

def initialize(claims)
  @claims = claims.transform_keys(&:to_s)
  @sub = @claims["sub"]
  @account_type = @claims["account_type"]
  @email = @claims["email"]
  @email_verified = @claims["email_verified"]
  @display_name = @claims["display_name"]
  @timezone = @claims["timezone"]
  @locale = @claims["locale"]
  @granted_scopes = Array(@claims["granted_scopes"])
  @required_scopes = Array(@claims["required_scopes"])
end

Instance Attribute Details

#account_typeObject (readonly)

Returns the value of attribute account_type.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def 
  @account_type
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def display_name
  @display_name
end

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def email
  @email
end

#email_verifiedObject (readonly)

Returns the value of attribute email_verified.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def email_verified
  @email_verified
end

#granted_scopesObject (readonly)

Returns the value of attribute granted_scopes.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def granted_scopes
  @granted_scopes
end

#localeObject (readonly)

Returns the value of attribute locale.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def locale
  @locale
end

#required_scopesObject (readonly)

Returns the value of attribute required_scopes.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def required_scopes
  @required_scopes
end

#subObject (readonly)

Returns the value of attribute sub.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def sub
  @sub
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



5
6
7
# File 'lib/honin/client/identity.rb', line 5

def timezone
  @timezone
end

Instance Method Details

#[](key) ⇒ Object

Access arbitrary JWT claims not covered by named attributes.



30
31
32
# File 'lib/honin/client/identity.rb', line 30

def [](key)
  @claims[key.to_s]
end

#anonymous?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/honin/client/identity.rb', line 21

def anonymous?
   == "anonymous"
end

#standard?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/honin/client/identity.rb', line 25

def standard?
   == "standard"
end

#to_hObject

Returns the full claims hash — use for session storage.



35
36
37
# File 'lib/honin/client/identity.rb', line 35

def to_h
  @claims.dup
end