Module: Policy::Base
- Included in:
- Node
- Defined in:
- lib/policy/base.rb,
lib/policy/base/or.rb,
lib/policy/base/and.rb,
lib/policy/base/not.rb,
lib/policy/base/xor.rb,
lib/policy/base/node.rb,
lib/policy/base/negator.rb
Overview
Policy object class interface
Includes ActiveModel::Validation
and a list of methods to compose policies.
Defined Under Namespace
Classes: And, Negator, Node, Not, Or, Xor
Class Method Summary collapse
Instance Method Summary collapse
-
#and(*others) ⇒ Object
Composes the policy with others by AND method.
-
#or(*others) ⇒ Object
Composes the policy with others by OR method.
-
#xor(*others) ⇒ Object
Composes the policy with others by XOR method.
Class Method Details
.included(klass) ⇒ Object
109 110 111 |
# File 'lib/policy/base.rb', line 109 def self.included(klass) klass.instance_eval { include ActiveModel::Validations } end |
Instance Method Details
#and(*others) ⇒ Policy::Base #and ⇒ #not
Composes the policy with others by AND method
39 40 41 |
# File 'lib/policy/base.rb', line 39 def and(*others) compose And, others end |
#or(*others) ⇒ Policy::Base #or ⇒ #not
Composes the policy with others by OR method
71 72 73 |
# File 'lib/policy/base.rb', line 71 def or(*others) compose Or, others end |
#xor(another) ⇒ Policy::Base #xor ⇒ #not
Composes the policy with others by XOR method
104 105 106 |
# File 'lib/policy/base.rb', line 104 def xor(*others) compose Xor, others end |