Class: Bouncer::User
- Inherits:
-
Object
- Object
- Bouncer::User
- Defined in:
- lib/bouncer-client/user.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#image ⇒ Object
Returns the value of attribute image.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#super_admin ⇒ Object
Returns the value of attribute super_admin.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/bouncer-client/user.rb', line 3 def created_at @created_at end |
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'lib/bouncer-client/user.rb', line 3 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/bouncer-client/user.rb', line 3 def id @id end |
#image ⇒ Object
Returns the value of attribute image.
3 4 5 |
# File 'lib/bouncer-client/user.rb', line 3 def image @image end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bouncer-client/user.rb', line 3 def name @name end |
#phone ⇒ Object
Returns the value of attribute phone.
3 4 5 |
# File 'lib/bouncer-client/user.rb', line 3 def phone @phone end |
#super_admin ⇒ Object
Returns the value of attribute super_admin.
3 4 5 |
# File 'lib/bouncer-client/user.rb', line 3 def super_admin @super_admin end |
Class Method Details
.from_id(id) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/bouncer-client/user.rb', line 5 def self.from_id id client = Bouncer::Client.current client.jwt(ENV['SERVICE_TOKEN'] || '') raw = client.user id from_json raw.body['users'][0] end |
.from_json(json) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/bouncer-client/user.rb', line 12 def self.from_json json user = User.new json.keys.map do |key| user.class.class_eval { attr_accessor key.to_sym } user.send("#{key}=", json[key]) end user end |
Instance Method Details
#super_admin? ⇒ Boolean
21 22 23 |
# File 'lib/bouncer-client/user.rb', line 21 def super_admin? @super_admin end |