Sha256: 4a4d36b4686db410d8d3e991e32f15bf1f7cbf69b15bf41689dcc5cef5c62ca8

Contents?: true

Size: 893 Bytes

Versions: 7

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
class SmartCore::Types::Primitive::NilableChecker
  # @param checker [Checker, SumChecker, MultChecker, NilableChecker]
  # @return [void]
  #
  # @api private
  # @since 0.1.0
  def initialize(checker)
    @checker = checker
  end

  # @param value [Any]
  # @return [Boolean]
  #
  # @api private
  # @since 0.1.0
  def call(value)
    # rubocop:disable Style/NilComparison
    # NOTE: #nil? is not used cuz BasicObject has no #nil? method
    (value == nil) ? true : checker.call(value)
    # rubocop:enable Style/NilComparison
  end

  private

  # @return [SmartCore::Types::Primitive::Checker]
  # @return [SmartCore::Types::Primitive::MultChecker]
  # @return [SmartCore::Types::Primitive::SumChecker]
  # @return [SmartCore::Types::Primitive::NilableChecker]
  #
  # @api private
  # @since 0.1.0
  attr_reader :checker
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smart_types-0.1.0 lib/smart_core/types/primitive/nilable_checker.rb
smart_types-0.1.0.alpha6 lib/smart_core/types/primitive/nilable_checker.rb
smart_types-0.1.0.alpha5 lib/smart_core/types/primitive/nilable_checker.rb
smart_types-0.1.0.alpha4 lib/smart_core/types/primitive/nilable_checker.rb
smart_types-0.1.0.alpha3 lib/smart_core/types/primitive/nilable_checker.rb
smart_types-0.1.0.alpha2 lib/smart_core/types/primitive/nilable_checker.rb
smart_types-0.1.0.alpha lib/smart_core/types/primitive/nilable_checker.rb