class Lamassu::PolicyContainer

Dry::Container with convenience methods when registering policy objects

Public Instance Methods

check(key, policy_object) click to toggle source

@param [String,Symbol] key @param [#call] policy_object

# File lib/lamassu/policy_container.rb, line 32
def check(key, policy_object)
  policy(key, PolicyAdapters::Check.new(policy_object))
end
for(scope, &block) click to toggle source

@param [Module] scope @param [Proc] block @return [PolicyContainer]

# File lib/lamassu/policy_container.rb, line 17
def for(scope, &block)
  container = PolicyContainer.new
  container.instance_eval(&block)

  merge(container, namespace: Lamassu.namespace_resolver.call(scope))
end
map(key, policy_object) click to toggle source

@param [String,Symbol] key @param [#call] policy_object

# File lib/lamassu/policy_container.rb, line 38
def map(key, policy_object)
  policy(key, PolicyAdapters::Map.new(policy_object))
end
policy(key, policy_object) click to toggle source

@param [String,Symbol] key @param [#call] policy_object

# File lib/lamassu/policy_container.rb, line 26
def policy(key, policy_object)
  register(key, policy_object, call: false)
end