Class: Policy::Follower::FollowedPolicy Private
- Inherits:
-
Object
- Object
- Policy::Follower::FollowedPolicy
- Defined in:
- lib/policy/follower/followed_policy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Stores the policy to be applied to all instances of the follower
The policy object can be set either as a constant, or by name in given namespace. Namespace and policy name can be set separately.
The separation is used at the #apply_policies.
Instance Attribute Summary collapse
-
#attributes ⇒ Array<Symbol>
readonly
private
The list of follower attributes to be send to the policy object.
-
#name ⇒ Symbol
readonly
private
The name for the policy.
-
#policy ⇒ Class
readonly
private
The policy object class to be followed.
Class Method Summary collapse
-
.initialize(namespace, policy, name, *attributes) ⇒ Policy::Follower::FollowedPolicy
private
Creates the immutable policy to be followed by given object.
Instance Method Summary collapse
-
#apply_to(follower) ⇒ undefined
private
Applies the policy to follower instance.
-
#new(namespace, policy, name, *attributes) ⇒ Policy::Follower::FollowedPolicy
Creates the immutable policy to be followed by given object.
Instance Attribute Details
#attributes ⇒ Array<Symbol> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The list of follower attributes to be send to the policy object
61 62 63 |
# File 'lib/policy/follower/followed_policy.rb', line 61 def attributes @attributes end |
#name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The name for the policy
49 50 51 |
# File 'lib/policy/follower/followed_policy.rb', line 49 def name @name end |
#policy ⇒ Class (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The policy object class to be followed
55 56 57 |
# File 'lib/policy/follower/followed_policy.rb', line 55 def policy @policy end |
Class Method Details
.initialize(namespace, policy, name, *attributes) ⇒ Policy::Follower::FollowedPolicy
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates the immutable policy to be followed by given object
39 40 41 42 43 |
# File 'lib/policy/follower/followed_policy.rb', line 39 def initialize(namespace, policy, name, *attributes) @policy = find_policy(namespace, policy) @name = (name || SecureRandom.uuid).to_sym @attributes = check_attributes attributes end |
Instance Method Details
#apply_to(follower) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Applies the policy to follower instance
72 73 74 |
# File 'lib/policy/follower/followed_policy.rb', line 72 def apply_to(follower) policy.apply(*attributes_of(follower)) end |
#new(namespace, policy, name, *attributes) ⇒ Policy::Follower::FollowedPolicy
Creates the immutable policy to be followed by given object
39 40 41 42 43 |
# File 'lib/policy/follower/followed_policy.rb', line 39 def initialize(namespace, policy, name, *attributes) @policy = find_policy(namespace, policy) @name = (name || SecureRandom.uuid).to_sym @attributes = check_attributes attributes end |