Class: SmartCore::Types::Primitive::InvariantControl::Chain Private
- Inherits:
-
Object
- Object
- SmartCore::Types::Primitive::InvariantControl::Chain
- Defined in:
- lib/smart_core/types/primitive/invariant_control/chain.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.
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
- #name ⇒ String readonly private
Instance Method Summary collapse
- #add_invariant(invariant) ⇒ void private
- #check(value, runtime_attributes) ⇒ SmartCore::Types::Primitive::InvariantControl::Chain::Result private
- #initialize(name) ⇒ void constructor private
- #simply_check(value, runtime_attributes) ⇒ Boolean private
Constructor Details
#initialize(name) ⇒ void
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.
20 21 22 23 |
# File 'lib/smart_core/types/primitive/invariant_control/chain.rb', line 20 def initialize(name) @name = name.dup.tap(&:freeze) @invariants = [] end |
Instance Attribute Details
#name ⇒ String (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.
13 14 15 |
# File 'lib/smart_core/types/primitive/invariant_control/chain.rb', line 13 def name @name end |
Instance Method Details
#add_invariant(invariant) ⇒ void
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.
This method returns an undefined value.
30 31 32 |
# File 'lib/smart_core/types/primitive/invariant_control/chain.rb', line 30 def add_invariant(invariant) invariants << invariant end |
#check(value, runtime_attributes) ⇒ SmartCore::Types::Primitive::InvariantControl::Chain::Result
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.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/smart_core/types/primitive/invariant_control/chain.rb', line 41 def check(value, runtime_attributes) invariant_results = [].tap do |results| invariants.each do |invariant| result = invariant.check(value, runtime_attributes).tap { |res| results << res } break if result.failure? end end SmartCore::Types::Primitive::InvariantControl::Chain::Result.new( self, value, invariant_results ) end |
#simply_check(value, runtime_attributes) ⇒ Boolean
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.
60 61 62 63 64 |
# File 'lib/smart_core/types/primitive/invariant_control/chain.rb', line 60 def simply_check(value, runtime_attributes) (invariants.any? do |invariant| invariant.simply_check(value, runtime_attributes) == false end) ? false : true end |