Module: Strategize::Policy::ClassMethods
- Defined in:
- lib/strategize/policies/policy.rb
Overview
These methods will be placed on the class that includes the Policy module.
Instance Method Summary collapse
-
#operation(name = :default, &block) ⇒ void
Define and add an [Operation] to the [OperationGroup] container.
-
#operations ⇒ OperationGroup
Get the [OperationGroup] container that has all the operations defined on the policy.
-
#rule(name, predicate) ⇒ void
Define and add a [Rule] to the [RuleGroup] container.
-
#rule_group ⇒ RuleGroup
Get the [RuleGroup] container that has all the rules defined on the policy.
Instance Method Details
#operation(name = :default, &block) ⇒ void
This method returns an undefined value.
Define and add an [Operation] to the [OperationGroup] container
43 44 45 |
# File 'lib/strategize/policies/policy.rb', line 43 def operation(name = :default, &block) operations.add(name, block) end |
#operations ⇒ OperationGroup
Get the [OperationGroup] container that has all the operations defined on the policy
25 26 27 |
# File 'lib/strategize/policies/policy.rb', line 25 def operations @operations ||= OperationGroup.new end |
#rule(name, predicate) ⇒ void
This method returns an undefined value.
Define and add a [Rule] to the [RuleGroup] container
34 35 36 |
# File 'lib/strategize/policies/policy.rb', line 34 def rule(name, predicate) rule_group.add(name, predicate) end |