Class: Stannum::Constraints::Delegator
- Extended by:
- Forwardable
- Defined in:
- lib/stannum/constraints/delegator.rb
Overview
A Delegator constraint delegates the constraint methods to a receiver.
Use the Delegator constraint when the behavior of a constraint needs to change based on the context. For example, a contract may use a Delegator constraint to wrap changes made after the contract is first initialized.
Constant Summary
Constants inherited from Base
Base::NEGATED_TYPE, Base::TYPE
Instance Attribute Summary collapse
-
#receiver ⇒ Stannum::Constraints::Base
The constraint that methods will be delegated to.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(receiver) ⇒ Delegator
constructor
A new instance of Delegator.
Methods inherited from Base
#==, #clone, #does_not_match?, #dup, #errors_for, #match, #matches?, #message, #negated_errors_for, #negated_match, #negated_message, #negated_type, #type, #with_options
Constructor Details
#initialize(receiver) ⇒ Delegator
Returns a new instance of Delegator.
30 31 32 33 34 |
# File 'lib/stannum/constraints/delegator.rb', line 30 def initialize(receiver) super() self.receiver = receiver end |
Instance Attribute Details
#receiver ⇒ Stannum::Constraints::Base
Returns the constraint that methods will be delegated to.
51 52 53 |
# File 'lib/stannum/constraints/delegator.rb', line 51 def receiver @receiver end |