Class: Bouncer::User

Inherits:
Object
  • Object
show all
Defined in:
lib/bouncer-client/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/bouncer-client/user.rb', line 3

def created_at
  @created_at
end

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/bouncer-client/user.rb', line 3

def email
  @email
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/bouncer-client/user.rb', line 3

def id
  @id
end

#imageObject

Returns the value of attribute image.



3
4
5
# File 'lib/bouncer-client/user.rb', line 3

def image
  @image
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/bouncer-client/user.rb', line 3

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



3
4
5
# File 'lib/bouncer-client/user.rb', line 3

def phone
  @phone
end

#super_adminObject

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/bouncer-client/user.rb', line 21

def super_admin?
  @super_admin
end