Class: Leash::User
- Inherits:
-
Object
- Object
- Leash::User
- Defined in:
- lib/leash/types.rb
Overview
Authenticated Leash user.
Mirrors the TS ‘LeashUser` interface — JSON fields use camelCase on the wire (`id`, `email`, `name`, `picture`), and on the Ruby side `picture` is optional. Two `LeashUser`s are equal when every attribute matches.
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#picture ⇒ Object
readonly
Returns the value of attribute picture.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(id:, email:, name: nil, picture: nil) ⇒ User
constructor
A new instance of User.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, email:, name: nil, picture: nil) ⇒ User
Returns a new instance of User.
12 13 14 15 16 17 |
# File 'lib/leash/types.rb', line 12 def initialize(id:, email:, name: nil, picture: nil) @id = id @email = email @name = name @picture = picture end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
10 11 12 |
# File 'lib/leash/types.rb', line 10 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/leash/types.rb', line 10 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/leash/types.rb', line 10 def name @name end |
#picture ⇒ Object (readonly)
Returns the value of attribute picture.
10 11 12 |
# File 'lib/leash/types.rb', line 10 def picture @picture end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
19 20 21 22 23 24 25 |
# File 'lib/leash/types.rb', line 19 def ==(other) other.is_a?(User) && id == other.id && email == other.email && name == other.name && picture == other.picture end |
#hash ⇒ Object
29 30 31 |
# File 'lib/leash/types.rb', line 29 def hash [self.class, id, email, name, picture].hash end |
#to_h ⇒ Object
33 34 35 36 37 |
# File 'lib/leash/types.rb', line 33 def to_h h = { id: id, email: email, name: name } h[:picture] = picture if picture h end |