module Strategize::Policy::ClassMethods
These methods will be placed on the class that includes the Policy
module.
Public Instance Methods
operation(name = :default, &block)
click to toggle source
Define and add an [Operation] to the [OperationGroup] container
@param name [Symbol] the name of the context for the operation @param block [Proc] the code block to execute @return [void]
# File lib/strategize/policies/policy.rb, line 43 def operation(name = :default, &block) operations.add(name, block) end
operations()
click to toggle source
Get the [OperationGroup] container that has all the operations defined on the policy
@return [OperationGroup]
# File lib/strategize/policies/policy.rb, line 25 def operations @operations ||= OperationGroup.new end
rule(name, predicate)
click to toggle source
Define and add a [Rule] to the [RuleGroup] container
@param name [Symbol] descriptive name for the rule @param predicate [Proc] code to execute @return [void]
# File lib/strategize/policies/policy.rb, line 34 def rule(name, predicate) rule_group.add(name, predicate) end
rule_group()
click to toggle source
Get the [RuleGroup] container that has all the rules defined on the policy
@return [RuleGroup]
# File lib/strategize/policies/policy.rb, line 17 def rule_group @rule_group ||= RuleGroup.new end