Module: Policy::Follower
- Defined in:
- lib/policy/follower.rb,
lib/policy/follower/policies.rb,
lib/policy/follower/name_error.rb,
lib/policy/follower/violation_error.rb
Overview
Interface for the class that follows policies
Defined Under Namespace
Modules: ClassMethods Classes: NameError, Policies, ViolationError
Class Method Summary collapse
Instance Method Summary collapse
-
#follow_policies?(*names) ⇒ true
Checks whether an object follows all its policies or subset of policies.
-
#follow_policy?(name) ⇒ true
Checks whether an object follows given policy.
Class Method Details
.included(klass) ⇒ Object
87 88 89 |
# File 'lib/policy/follower.rb', line 87 def self.included(klass) klass.instance_eval { extend ClassMethods } end |
Instance Method Details
#follow_policies? ⇒ true #follow_policies?(names) ⇒ true
Checks whether an object follows all its policies or subset of policies
66 67 68 69 70 71 72 |
# File 'lib/policy/follower.rb', line 66 def follow_policies?(*names) __policies__ .subset(names) # raises NameError .map(&method(:__send__)) # raises NoMethodError .each(&method(:__validate_policy__)) # raises ViolationError true end |
#follow_policy?(name) ⇒ true
Checks whether an object follows given policy
82 83 84 |
# File 'lib/policy/follower.rb', line 82 def follow_policy?(name) follow_policies? name end |