Class: Critic::Authorization

Inherits:
Object
  • Object
show all
Defined in:
lib/critic/authorization.rb

Overview

Represents an authorization result for a policy and action

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(policy, action) ⇒ Authorization

Returns a new instance of Authorization.



7
8
9
10
11
12
13
14
# File 'lib/critic/authorization.rb', line 7

def initialize(policy, action)
  @policy = policy
  @action = action&.to_sym

  @metadata = {}
  @granted, @result = nil
  @messages = []
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



4
5
6
# File 'lib/critic/authorization.rb', line 4

def action
  @action
end

#grantedObject

Returns the value of attribute granted.



5
6
7
# File 'lib/critic/authorization.rb', line 5

def granted
  @granted
end

#messagesObject

Returns the value of attribute messages.



5
6
7
# File 'lib/critic/authorization.rb', line 5

def messages
  @messages
end

#metadataObject

Returns the value of attribute metadata.



5
6
7
# File 'lib/critic/authorization.rb', line 5

def 
  @metadata
end

#policyObject (readonly)

Returns the value of attribute policy.



4
5
6
# File 'lib/critic/authorization.rb', line 4

def policy
  @policy
end

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/critic/authorization.rb', line 5

def result
  @result
end

Instance Method Details

#denied?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/critic/authorization.rb', line 20

def denied?
  false == @granted
end

#granted?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/critic/authorization.rb', line 16

def granted?
  true == @granted
end