Class: ResourcePolicy::Policy::ActionPolicyConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/resource_policy/policy/action_policy_configuration.rb

Overview

Stores configuration for action policy.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, policy_configuration:) ⇒ ActionPolicyConfiguration

Returns a new instance of ActionPolicyConfiguration.



11
12
13
14
15
16
# File 'lib/resource_policy/policy/action_policy_configuration.rb', line 11

def initialize(name, policy_configuration:)
  @name = name.to_sym
  @policy_configuration = policy_configuration
  @extra_conditions = []
  @configured = false
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/resource_policy/policy/action_policy_configuration.rb', line 9

def name
  @name
end

Instance Method Details

#allowed(options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/resource_policy/policy/action_policy_configuration.rb', line 18

def allowed(options = {})
  @extra_conditions = (@extra_conditions + Array(options[:if])).uniq
  @configured = true
  self
end

#conditionsObject



24
25
26
# File 'lib/resource_policy/policy/action_policy_configuration.rb', line 24

def conditions
  policy_configuration.group_conditions + @extra_conditions
end

#configured?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/resource_policy/policy/action_policy_configuration.rb', line 28

def configured?
  @configured
end