Class: Critic::Authorization

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(policy, action) ⇒ Authorization

Returns a new instance of Authorization.



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

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.



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

def action
  @action
end

#grantedObject

Returns the value of attribute granted.



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

def granted
  @granted
end

#messagesObject

Returns the value of attribute messages.



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

def messages
  @messages
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  @metadata
end

#policyObject (readonly)

Returns the value of attribute policy.



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

def policy
  @policy
end

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

Instance Method Details

#denied?Boolean

Returns:

  • (Boolean)


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

def denied?
  false == @granted
end

#granted?Boolean

Returns:

  • (Boolean)


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

def granted?
  true == @granted
end