Class: SmartCore::Initializer::TypeSystem::ThyTypes::AbstractFactory Private

Inherits:
Interop::AbstractFactory show all
Defined in:
lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Constant Summary collapse

GENERIC_TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns:

  • (Thy::Type)

Since:

  • 0.1.0

::Thy::Type.new { true }

Class Method Summary collapse

Methods inherited from Interop::AbstractFactory

create

Class Method Details

.build_cast_operation(type) ⇒ SmartCore::Initializer::TypeSystem::ThyTypes::Operation::Cast

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • type (Thy::Type, #check)

Returns:

Since:

  • 0.1.0



71
72
73
# File 'lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb', line 71

def build_cast_operation(type)
  ThyTypes::Operation::Cast.new(type)
end

.build_identifier(type) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • type (Any)

Returns:

  • (String)

Since:

  • 0.5.1



36
37
38
# File 'lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb', line 36

def build_identifier(type)
  type.name
end

.build_interop(identifier, valid_op, validate_op, cast_op) ⇒ SmartCore::Initializer::TypeSystem::ThyTypes

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



84
85
86
# File 'lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb', line 84

def build_interop(identifier, valid_op, validate_op, cast_op)
  ThyTypes.new(identifier, valid_op, validate_op, cast_op)
end

.build_valid_operation(type) ⇒ SmartCore::Initializer::TypeSystem::ThyTypes::Operation::Valid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • type (Thy::Type, #check)

Returns:

Since:

  • 0.1.0



45
46
47
# File 'lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb', line 45

def build_valid_operation(type)
  ThyTypes::Operation::Valid.new(type)
end

.build_validate_operation(type) ⇒ SmartCore::Initializer::TypeSystem::ThyTypes::Operation::Validate

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • type (Thy::Type, #check)

Returns:

Since:

  • 0.1.0



62
63
64
# File 'lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb', line 62

def build_validate_operation(type)
  ThyTypes::Operation::Validate.new(type)
end

.generic_type_objectThy::Type, #check

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Thy::Type, #check)

Since:

  • 0.1.0



53
54
55
# File 'lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb', line 53

def generic_type_object
  GENERIC_TYPE
end

.prevent_incompatible_type!(type) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • type (Thy::Type, #check)

Raises:

Since:

  • 0.1.0



21
22
23
24
25
26
27
28
29
# File 'lib/smart_core/initializer/plugins/thy_types/thy_types/abstract_factory.rb', line 21

def prevent_incompatible_type!(type)
  unless type.respond_to?(:check) || type.is_a?(::Thy::Type)
    raise(
      SmartCore::Initializer::IncorrectTypeObjectError,
      'Incorrect Thy::Type primitive ' \
      '(type object should respond to :check method)'
    )
  end
end