Sha256: 182396442779436f2e109102a452aa5fbe2a4415a041ef3e26d8a6f9a1f65c63

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
class SmartCore::Types::Primitive::Factory::DefinitionContext
  # @return [Proc, NilClass]
  #
  # @api private
  # @since 0.1.0
  attr_reader :type_checker

  # @return [Proc, NilClass]
  #
  # @api private
  # @since 0.1.0
  attr_reader :type_caster

  # @return [void]
  #
  # @api private
  # @since 0.1.0
  def initialize
    @type_checker = nil
    @type_caster = nil
  end

  # @param checker [Block]
  # @return [void]
  #
  # @api public
  # @since 0.1.0
  def define_checker(&checker)
    raise(SmartCore::ArgumentError, 'No checker definition block') unless block_given?
    @type_checker = checker
  end

  # @param caster [Block]
  # @return [void]
  #
  # @api public
  # @since 0.1.0
  def define_caster(&caster)
    raise(SmartCore::ArgumentError, 'No caster definition block') unless block_given?
    @type_caster = caster
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_types-0.1.0 lib/smart_core/types/primitive/factory/definition_context.rb