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.



10
11
12
13
14
15
16
17
# File 'lib/hachi/models/user.rb', line 10

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.



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

def name
  @name
end

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#rolesObject (readonly)

Returns the value of attribute roles.



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

def roles
  @roles
end

Instance Method Details

#payloadObject



19
20
21
22
23
24
25
26
# File 'lib/hachi/models/user.rb', line 19

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