Class: HoninClient::Identity
- Inherits:
-
Object
- Object
- HoninClient::Identity
- Defined in:
- lib/honin/client/identity.rb
Instance Attribute Summary collapse
-
#account_type ⇒ Object
readonly
Returns the value of attribute account_type.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#email_verified ⇒ Object
readonly
Returns the value of attribute email_verified.
-
#granted_scopes ⇒ Object
readonly
Returns the value of attribute granted_scopes.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#required_scopes ⇒ Object
readonly
Returns the value of attribute required_scopes.
-
#sub ⇒ Object
readonly
Returns the value of attribute sub.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Access arbitrary JWT claims not covered by named attributes.
- #anonymous? ⇒ Boolean
-
#initialize(claims) ⇒ Identity
constructor
A new instance of Identity.
- #standard? ⇒ Boolean
-
#to_h ⇒ Object
Returns the full claims hash — use for session storage.
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_type ⇒ Object (readonly)
Returns the value of attribute account_type.
5 6 7 |
# File 'lib/honin/client/identity.rb', line 5 def account_type @account_type end |
#display_name ⇒ Object (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 |
#email ⇒ Object (readonly)
Returns the value of attribute email.
5 6 7 |
# File 'lib/honin/client/identity.rb', line 5 def email @email end |
#email_verified ⇒ Object (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_scopes ⇒ Object (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 |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
5 6 7 |
# File 'lib/honin/client/identity.rb', line 5 def locale @locale end |
#required_scopes ⇒ Object (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 |
#sub ⇒ Object (readonly)
Returns the value of attribute sub.
5 6 7 |
# File 'lib/honin/client/identity.rb', line 5 def sub @sub end |
#timezone ⇒ Object (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
21 22 23 |
# File 'lib/honin/client/identity.rb', line 21 def anonymous? account_type == "anonymous" end |
#standard? ⇒ Boolean
25 26 27 |
# File 'lib/honin/client/identity.rb', line 25 def standard? account_type == "standard" end |
#to_h ⇒ Object
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 |