Sha256: da449043521b9eba5a5f6e6f2fcf81d85e321f702578c5e5e8b3eabce2e415b0
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true # @api private # @since 0.2.0 class SmartCore::Types::Primitive::InvariantControl::Chain require_relative 'chain/result' # @return [String] # # @api private # @since 0.2.0 attr_reader :name # @param name [String] # @return [void] # # @api private # @since 0.1.0 def initialize(name) @name = name.dup.tap(&:freeze) @invariants = [] end # @param invariant [SmartCore::Types::Primitive::InvariantControl::Single] # @return [void] # # @api private # @since 0.2.0 def add_invariant(invariant) invariants << invariant end # @param value [Any] # @return [SmartCore::Types::Primitive::InvariantControl::Chain::Result] # # @api private # @since 0.2.0 def check(value) invariant_results = [].tap do |results| invariants.each do |invariant| result = invariant.check(value).tap { |res| results << res } break if result.failure? end end SmartCore::Types::Primitive::InvariantControl::Chain::Result.new( self, value, invariant_results ) end private # @return [Array<SmartCore::Types::Primitive::InvariantControl::Single>] # # @api private # @since 0.2.0 attr_reader :invariants end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smart_types-0.2.0 | lib/smart_core/types/primitive/invariant_control/chain.rb |