Module: Policy::Follower
- Extended by:
- ClassMethods
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/policy/follower.rb,
lib/policy/follower/names.rb,
lib/policy/follower/followed_policy.rb,
lib/policy/follower/followed_policies.rb
Overview
Adds features for the object to follow external policies
Defined Under Namespace
Modules: ClassMethods, Names Classes: FollowedPolicies, FollowedPolicy
Instance Method Summary collapse
-
#follow_policies!(*names) ⇒ undefined
Checks whether an instance meets selected policies.
-
#follow_policies?(*names) ⇒ Boolean
Safely checks whether an instance meets selected policies.
-
#follow_policy!(name) ⇒ undefined
Syntax shugar for the #follow_policies! with one argument.
-
#follow_policy?(name) ⇒ Boolean
Syntax shugar for the #follow_policies? with one argument.
Methods included from ClassMethods
Instance Method Details
#follow_policies!(*names) ⇒ undefined
Checks whether an instance meets selected policies
Mutates the object by adding new #errors
83 84 85 86 87 88 |
# File 'lib/policy/follower.rb', line 83 def follow_policies!(*names) followed_policies.apply_to self, *names rescue ViolationError => error collect_errors_from(error) raise end |
#follow_policies?(*names) ⇒ Boolean
Safely checks whether an instance meets selected policies
Mutates the object by adding new #errors
109 110 111 112 113 114 |
# File 'lib/policy/follower.rb', line 109 def follow_policies?(*names) follow_policies!(*names) true rescue ViolationError false end |
#follow_policy!(name) ⇒ undefined
Syntax shugar for the #follow_policies! with one argument
98 99 100 |
# File 'lib/policy/follower.rb', line 98 def follow_policy!(name) follow_policies! name end |
#follow_policy?(name) ⇒ Boolean
Syntax shugar for the #follow_policies? with one argument
121 122 123 |
# File 'lib/policy/follower.rb', line 121 def follow_policy?(name) follow_policies? name end |