Class: RoleCore::Permission

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

Direct Known Subclasses

CanCanCanPermission

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, _namespace: [], _priority: 0, _callable: false, **options, &block) ⇒ Permission

Returns a new instance of Permission.



7
8
9
10
11
12
# File 'lib/role_core/permission.rb', line 7

def initialize(name, _namespace: [], _priority: 0, _callable: false, **options, &block)
  @name = name
  @namespace = _namespace
  @priority = _priority
  @callable = _callable
end

Instance Attribute Details

#callableObject (readonly)

Returns the value of attribute callable.



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

def callable
  @callable
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



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

def namespace
  @namespace
end

#priorityObject (readonly)

Returns the value of attribute priority.



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

def priority
  @priority
end

Instance Method Details

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



22
23
24
25
26
27
28
# File 'lib/role_core/permission.rb', line 22

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

  instance_values == other.instance_values
end

#call(context) ⇒ Object

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/role_core/permission.rb', line 14

def call(context, *)
  raise NotImplementedError
end

#hashObject



18
19
20
# File 'lib/role_core/permission.rb', line 18

def hash
  instance_values.hash
end