Class: Aegis::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/aegis/role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Role

Returns a new instance of Role.



6
7
8
9
10
# File 'lib/aegis/role.rb', line 6

def initialize(name, options)
  @name = name
  @default_permission = options[:default_permission] == :allow ? :allow : :deny
  freeze
end

Instance Attribute Details

#default_permissionObject (readonly)

Returns the value of attribute default_permission.



4
5
6
# File 'lib/aegis/role.rb', line 4

def default_permission
  @default_permission
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/aegis/role.rb', line 4

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



16
17
18
# File 'lib/aegis/role.rb', line 16

def <=>(other)
  name <=> other.name
end

#may_by_default?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/aegis/role.rb', line 12

def may_by_default?
  @default_permission == :allow
end

#to_sObject



20
21
22
# File 'lib/aegis/role.rb', line 20

def to_s
  name.to_s.humanize
end