Class: Roleback::Definitions::RuleBased

Inherits:
Object
  • Object
show all
Defined in:
lib/roleback/definitions/rule_based.rb

Direct Known Subclasses

Resource, Role, Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role:, resource:, scope:) ⇒ RuleBased

Returns a new instance of RuleBased.



7
8
9
10
11
# File 'lib/roleback/definitions/rule_based.rb', line 7

def initialize(role:, resource:, scope:)
	@role = role
	@resource = resource
	@scope = scope
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



5
6
7
# File 'lib/roleback/definitions/rule_based.rb', line 5

def resource
  @resource
end

#roleObject (readonly)

Returns the value of attribute role.



4
5
6
# File 'lib/roleback/definitions/rule_based.rb', line 4

def role
  @role
end

Instance Method Details

#<=>(other) ⇒ Object



21
22
23
# File 'lib/roleback/definitions/rule_based.rb', line 21

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

#can(action) ⇒ Object



13
14
15
# File 'lib/roleback/definitions/rule_based.rb', line 13

def can(action)
	do_rule(role: @role, resource: @resource, scope: @scope, action: action, outcome: ::Roleback::ALLOW)
end

#cannot(action) ⇒ Object



17
18
19
# File 'lib/roleback/definitions/rule_based.rb', line 17

def cannot(action)
	do_rule(role: @role, resource: @resource, scope: @scope, action: action, outcome: ::Roleback::DENY)
end