Sha256: ed1c3f884fd6ae91a7cf51808a2b4b7458bf0709fb49e24f89cd4d053af8b0a1
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true # @api private # @since 0.2.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] # @return [SmartCore::Types::Primitive::InvariantControl::Single::Result] # # @api private # @since 0.2.0 def check(value) validation_result = !!invariant_checker.call(value) Result.new(self, value, validation_result) 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.2.0 | lib/smart_core/types/primitive/invariant_control/single.rb |