Class: RbacCore::Permission

Inherits:
Object
  • Object
show all
Defined in:
lib/rbac_core/permission.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, priority: 0, **options, &block) ⇒ Permission

Returns a new instance of Permission.



7
8
9
10
# File 'lib/rbac_core/permission.rb', line 7

def initialize(name, priority: 0, **options, &block)
  @name = name
  @priority = priority
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/rbac_core/permission.rb', line 5

def name
  @name
end

#priorityObject (readonly)

Returns the value of attribute priority.



5
6
7
# File 'lib/rbac_core/permission.rb', line 5

def priority
  @priority
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



20
21
22
23
24
25
26
# File 'lib/rbac_core/permission.rb', line 20

def ==(other)
  unless other.is_a?(RbacCore::Permission)
    return false
  end

  instance_values == other.instance_values
end

#call(context) ⇒ Object

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/rbac_core/permission.rb', line 12

def call(context, *)
  raise NotImplementedError
end

#hashObject



16
17
18
# File 'lib/rbac_core/permission.rb', line 16

def hash
  instance_values.hash
end