Sha256: d564548e295326976ac61201f73968f7f03d9bb7809b901b88b5c3593a7733d1
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true # @api private # @since 0.2.0 # @version 0.8.0 class SmartCore::Types::Primitive::InvariantControl::Single require_relative 'single/result' class << self # @param name [String, Symbol] # @param invariant_checker [Proc] # @return [SmartCore::Types::Primitive::InvariantControl::Single] # # @api private # @since 0.2.0 def create(name, invariant_checker) new(name.to_s, invariant_checker) end end # @return [String] # # @api private # @since 0.2.0 attr_reader :name # @param name [String] # @param invariant_checker [Proc] # @return [void] # # @api private # @since 0.2.0 def initialize(name, invariant_checker) @name = name.dup.tap(&:freeze) @invariant_checker = invariant_checker end # @param value [Any] # @param runtime_attributes [Array<Any>] # @return [SmartCore::Types::Primitive::InvariantControl::Single::Result] # # @api private # @since 0.2.0 # @version 0.3.0 def check(value, runtime_attributes) validation_result = !!invariant_checker.call(value, runtime_attributes) Result.new(self, value, validation_result) end # @param value [Any] # @param runtime_attributes [Array<Any>] # @return [Boolean] # # @api private # @since 0.8.0 def simply_check(value, runtime_attributes) !!invariant_checker.call(value, runtime_attributes) end private # @return [Proc] # # @api private # @since 0.2.0 attr_reader :invariant_checker end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smart_types-0.8.0 | lib/smart_core/types/primitive/invariant_control/single.rb |