Sha256: e4a299cd691f88b371576fec974fd0549e0c3e4080463ef5e25c056c5168c7b0

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
# @version 0.3.0
class SmartCore::Types::Primitive::SumFactory::DefinitionContext
  # @return [Proc, NilClass]
  #
  # @api private
  # @since 0.1.0
  attr_reader :type_caster

  # @return [Proc, NilClass]
  #
  # @api private
  # @since 0.3.0
  attr_reader :type_runtime_attributes_checker

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

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

  # @param definition [Block]
  # @return [void]
  #
  # @api public
  # @since 0.3.0
  def runtime_attributes_checker(&definition)
    unless block_given?
      raise(SmartCore::Types::TypeDefinitionError, 'No runtime checker definition block')
    end
    @type_runtime_attributes_checker = definition
  end

  # TODO (0.x.0): invariant API
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smart_types-0.8.0 lib/smart_core/types/primitive/sum_factory/definition_context.rb
smart_types-0.7.1 lib/smart_core/types/primitive/sum_factory/definition_context.rb
smart_types-0.7.0 lib/smart_core/types/primitive/sum_factory/definition_context.rb
smart_types-0.6.0 lib/smart_core/types/primitive/sum_factory/definition_context.rb
smart_types-0.4.0 lib/smart_core/types/primitive/sum_factory/definition_context.rb
smart_types-0.3.0 lib/smart_core/types/primitive/sum_factory/definition_context.rb