Class: Etna::Permission

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

Constant Summary collapse

ROLE_NAMES =
{
  "A" => :admin,
  "E" => :editor,
  "V" => :viewer,
  "G" => :guest
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role_key, project_name) ⇒ Permission

Returns a new instance of Permission.



74
75
76
77
78
# File 'lib/etna/permissions.rb', line 74

def initialize(role_key, project_name)
  @role_key = role_key
  @role = Etna::Role.new(ROLE_NAMES[role_key.upcase], role_key == role_key.upcase)
  @project_name = project_name
end

Instance Attribute Details

#project_nameObject (readonly)

Returns the value of attribute project_name.



65
66
67
# File 'lib/etna/permissions.rb', line 65

def project_name
  @project_name
end

#roleObject (readonly)

Returns the value of attribute role.



65
66
67
# File 'lib/etna/permissions.rb', line 65

def role
  @role
end

#role_keyObject (readonly)

Returns the value of attribute role_key.



65
66
67
# File 'lib/etna/permissions.rb', line 65

def role_key
  @role_key
end

Instance Method Details

#to_hashObject



80
81
82
# File 'lib/etna/permissions.rb', line 80

def to_hash
  role.to_hash
end