Class: Hachi::Models::User

Inherits:
Base
  • Object
show all
Defined in:
lib/hachi/models/user.rb

Constant Summary collapse

ROLES =
%w(read write admin).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(login:, name:, roles:, password:) ⇒ User

Returns a new instance of User.



13
14
15
16
17
18
19
20
# File 'lib/hachi/models/user.rb', line 13

def initialize(login:, name:, roles:, password:)
  @login = 
  @name = name
  @roles = roles
  @password = password

  validate_roles
end

Instance Attribute Details

#loginObject (readonly)

Returns the value of attribute login.



6
7
8
# File 'lib/hachi/models/user.rb', line 6

def 
  @login
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/hachi/models/user.rb', line 7

def name
  @name
end

#passwordObject (readonly)

Returns the value of attribute password.



9
10
11
# File 'lib/hachi/models/user.rb', line 9

def password
  @password
end

#rolesObject (readonly)

Returns the value of attribute roles.



8
9
10
# File 'lib/hachi/models/user.rb', line 8

def roles
  @roles
end

Instance Method Details

#payloadObject



22
23
24
25
26
27
28
29
# File 'lib/hachi/models/user.rb', line 22

def payload
  {
    login: ,
    name: name,
    roles: roles,
    password: password
  }.compact
end