Class: Etna::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/etna/permissions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role, restricted) ⇒ Role

Returns a new instance of Role.



87
88
89
90
# File 'lib/etna/permissions.rb', line 87

def initialize(role, restricted)
  @role = role
  @restricted = restricted
end

Instance Attribute Details

#restrictedObject (readonly)

Returns the value of attribute restricted.



86
87
88
# File 'lib/etna/permissions.rb', line 86

def restricted
  @restricted
end

#roleObject (readonly)

Returns the value of attribute role.



86
87
88
# File 'lib/etna/permissions.rb', line 86

def role
  @role
end

Instance Method Details

#keyObject



92
93
94
95
# File 'lib/etna/permissions.rb', line 92

def key
  role_key = role.to_s[0]
  restricted ? role_key.upcase : role_key
end

#to_hashObject



97
98
99
100
101
102
# File 'lib/etna/permissions.rb', line 97

def to_hash
  {
    role: role,
    restricted: restricted,
  }
end