smart_schema 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. metadata +3 -83
  3. data/.gitignore +0 -12
  4. data/.rspec +0 -3
  5. data/.rubocop.yml +0 -20
  6. data/CHANGELOG.md +0 -79
  7. data/CODE_OF_CONDUCT.md +0 -74
  8. data/Gemfile +0 -5
  9. data/Gemfile.lock +0 -266
  10. data/LICENSE.txt +0 -21
  11. data/README.md +0 -305
  12. data/Rakefile +0 -21
  13. data/bin/console +0 -8
  14. data/bin/setup +0 -8
  15. data/lib/smart_core/schema/checker/reconciler/constructor.rb +0 -60
  16. data/lib/smart_core/schema/checker/reconciler/matcher/options.rb +0 -33
  17. data/lib/smart_core/schema/checker/reconciler/matcher/result.rb +0 -87
  18. data/lib/smart_core/schema/checker/reconciler/matcher/result_finalizer.rb +0 -186
  19. data/lib/smart_core/schema/checker/reconciler/matcher.rb +0 -62
  20. data/lib/smart_core/schema/checker/reconciler.rb +0 -106
  21. data/lib/smart_core/schema/checker/rules/base.rb +0 -110
  22. data/lib/smart_core/schema/checker/rules/extra_keys/failure.rb +0 -24
  23. data/lib/smart_core/schema/checker/rules/extra_keys/result.rb +0 -37
  24. data/lib/smart_core/schema/checker/rules/extra_keys/success.rb +0 -30
  25. data/lib/smart_core/schema/checker/rules/extra_keys.rb +0 -31
  26. data/lib/smart_core/schema/checker/rules/optional.rb +0 -27
  27. data/lib/smart_core/schema/checker/rules/options/empty.rb +0 -43
  28. data/lib/smart_core/schema/checker/rules/options/filled.rb +0 -49
  29. data/lib/smart_core/schema/checker/rules/options/type.rb +0 -88
  30. data/lib/smart_core/schema/checker/rules/options.rb +0 -60
  31. data/lib/smart_core/schema/checker/rules/required.rb +0 -27
  32. data/lib/smart_core/schema/checker/rules/requirement/optional.rb +0 -36
  33. data/lib/smart_core/schema/checker/rules/requirement/required.rb +0 -36
  34. data/lib/smart_core/schema/checker/rules/requirement/result.rb +0 -95
  35. data/lib/smart_core/schema/checker/rules/requirement.rb +0 -9
  36. data/lib/smart_core/schema/checker/rules/result/base.rb +0 -44
  37. data/lib/smart_core/schema/checker/rules/result/failure.rb +0 -41
  38. data/lib/smart_core/schema/checker/rules/result/success.rb +0 -15
  39. data/lib/smart_core/schema/checker/rules/result.rb +0 -9
  40. data/lib/smart_core/schema/checker/rules/type_aliases.rb +0 -57
  41. data/lib/smart_core/schema/checker/rules/verifier/result.rb +0 -75
  42. data/lib/smart_core/schema/checker/rules/verifier.rb +0 -74
  43. data/lib/smart_core/schema/checker/rules.rb +0 -89
  44. data/lib/smart_core/schema/checker/verifiable_hash.rb +0 -65
  45. data/lib/smart_core/schema/checker.rb +0 -106
  46. data/lib/smart_core/schema/configuration.rb +0 -33
  47. data/lib/smart_core/schema/dsl.rb +0 -81
  48. data/lib/smart_core/schema/errors.rb +0 -65
  49. data/lib/smart_core/schema/key_control.rb +0 -39
  50. data/lib/smart_core/schema/plugins/abstract.rb +0 -55
  51. data/lib/smart_core/schema/plugins/access_mixin.rb +0 -47
  52. data/lib/smart_core/schema/plugins/dry_types/dry_types/abstract_factory.rb +0 -91
  53. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/base.rb +0 -9
  54. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/cast.rb +0 -21
  55. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/valid.rb +0 -16
  56. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/validate.rb +0 -19
  57. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation.rb +0 -12
  58. data/lib/smart_core/schema/plugins/dry_types/dry_types.rb +0 -10
  59. data/lib/smart_core/schema/plugins/dry_types/errors.rb +0 -13
  60. data/lib/smart_core/schema/plugins/dry_types.rb +0 -27
  61. data/lib/smart_core/schema/plugins/registry.rb +0 -158
  62. data/lib/smart_core/schema/plugins/registry_interface.rb +0 -63
  63. data/lib/smart_core/schema/plugins.rb +0 -17
  64. data/lib/smart_core/schema/result.rb +0 -62
  65. data/lib/smart_core/schema/type_system/interop/abstract_factory.rb +0 -80
  66. data/lib/smart_core/schema/type_system/interop/aliasing/alias_list.rb +0 -131
  67. data/lib/smart_core/schema/type_system/interop/aliasing.rb +0 -72
  68. data/lib/smart_core/schema/type_system/interop/operation.rb +0 -30
  69. data/lib/smart_core/schema/type_system/interop.rb +0 -120
  70. data/lib/smart_core/schema/type_system/registry.rb +0 -162
  71. data/lib/smart_core/schema/type_system/registry_interface.rb +0 -87
  72. data/lib/smart_core/schema/type_system/smart_types/abstract_factory.rb +0 -91
  73. data/lib/smart_core/schema/type_system/smart_types/operation/base.rb +0 -8
  74. data/lib/smart_core/schema/type_system/smart_types/operation/cast.rb +0 -16
  75. data/lib/smart_core/schema/type_system/smart_types/operation/valid.rb +0 -16
  76. data/lib/smart_core/schema/type_system/smart_types/operation/validate.rb +0 -16
  77. data/lib/smart_core/schema/type_system/smart_types/operation.rb +0 -13
  78. data/lib/smart_core/schema/type_system/smart_types.rb +0 -48
  79. data/lib/smart_core/schema/type_system.rb +0 -16
  80. data/lib/smart_core/schema/version.rb +0 -14
  81. data/lib/smart_core/schema.rb +0 -67
  82. data/smart_schema.gemspec +0 -46
@@ -1,131 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.12.0
5
- class SmartCore::Schema::TypeSystem::Interop::Aliasing::AliasList
6
- # @param interop_klass [Class<SmartCore::Schema::TypeSystem::Interop>]
7
- # @return [void]
8
- #
9
- # @api private
10
- # @since 0.12.0
11
- def initialize(interop_klass)
12
- @interop_klass = interop_klass
13
- @list = {}
14
- @lock = SmartCore::Engine::ReadWriteLock.new
15
- end
16
-
17
- # @return [Array<String>]
18
- #
19
- # @api private
20
- # @since 0.12.0
21
- def keys
22
- @lock.read_sync { registered_aliases }
23
- end
24
-
25
- # @return [Hash<String,Any>]
26
- #
27
- # @api private
28
- # @since 0.12.0
29
- def to_h
30
- @lock.read_sync { transform_to_hash }
31
- end
32
- alias_method :to_hash, :to_h
33
-
34
- # @param alias_name [String, Symbol]
35
- # @param type [Any]
36
- # @return [void]
37
- #
38
- # @api private
39
- # @since 0.12.0
40
- def associate(alias_name, type)
41
- interop_klass.prevent_incompatible_type!(type)
42
- @lock.write_sync { set_alias(alias_name, type) }
43
- end
44
-
45
- # @param alias_name [String, Symbol]
46
- # @return [Any]
47
- #
48
- # @api private
49
- # @since 0.12.0
50
- def resolve(alias_name)
51
- @lock.read_sync { get_alias(alias_name) }
52
- end
53
-
54
- private
55
-
56
- # @return [Hash<String,Any>]
57
- #
58
- # @api private
59
- # @since 0.12.0
60
- attr_reader :list
61
-
62
- # @return [Class<SmartCore::Schema::TypeSystem::Interop>]
63
- #
64
- # @api private
65
- # @since 0.12.0
66
- attr_reader :interop_klass
67
-
68
- # @param alias_name [String, Symbol]
69
- # @param type [Any]
70
- # @return [void]
71
- #
72
- # @api private
73
- # @since 0.12.0
74
- def set_alias(alias_name, type)
75
- alias_name = normalized_alias(alias_name)
76
-
77
- if list.key?(alias_name)
78
- ::Warning.warn(
79
- "[#{interop_klass.name}] Shadowing of the already existing \"#{alias_name}\" type alias."
80
- )
81
- end
82
-
83
- list[alias_name] = type
84
- end
85
-
86
- # @param alias_name [String, Symbol]
87
- # @return [Any]
88
- #
89
- # @api private
90
- # @since 0.12.0
91
- def get_alias(alias_name)
92
- alias_name = normalized_alias(alias_name)
93
-
94
- raise(
95
- SmartCore::Schema::TypeAliasNotFoundError,
96
- "Alias with name `#{alias_name}` not found."
97
- ) unless list.key?(alias_name)
98
-
99
- list.fetch(alias_name)
100
- end
101
-
102
- # @param alias_name [String, Symbol]
103
- # @return [String]
104
- #
105
- # @api private
106
- # @since 0.12.0
107
- def normalized_alias(alias_name)
108
- raise(
109
- SmartCore::Schema::ArgumentError,
110
- 'Type alias should be a type of string or symbol'
111
- ) unless alias_name.is_a?(String) || alias_name.is_a?(Symbol)
112
-
113
- alias_name.to_s
114
- end
115
-
116
- # @return [Hash<String,Any>]
117
- #
118
- # @api private
119
- # @since 0.12.0
120
- def transform_to_hash
121
- list.to_h
122
- end
123
-
124
- # @return [Array<String>]
125
- #
126
- # @api private
127
- # @since 0.12.0
128
- def registered_aliases
129
- list.keys
130
- end
131
- end
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @version 0.12.0
5
- module SmartCore::Schema::TypeSystem::Interop::Aliasing
6
- require_relative 'aliasing/alias_list'
7
-
8
- class << self
9
- # @param base_klass [Class]
10
- # @return [void]
11
- #
12
- # @api private
13
- # @version 0.12.0
14
- def included(base_klass)
15
- base_klass.extend(ClassMethods)
16
- base_klass.singleton_class.prepend(ClassInheritance)
17
- end
18
- end
19
-
20
- # @api private
21
- # @version 0.12.0
22
- module ClassInheritance
23
- # @param child_klass [Class<SmartCore::Schema::TypeSystem::Interop>]
24
- # @return [void]
25
- #
26
- # @api private
27
- # @version 0.12.0
28
- def inherited(child_klass)
29
- child_klass.instance_variable_set(:@__type_aliases__, AliasList.new(child_klass))
30
- super
31
- end
32
- end
33
-
34
- # @api private
35
- # @version 0.12.0
36
- module ClassMethods
37
- # @return [SmartCore::Schema::TypeSystem::Interop::Aliasing::AliasList]
38
- #
39
- # @api private
40
- # @version 0.12.0
41
- def __type_aliases__
42
- @__type_aliases__
43
- end
44
-
45
- # @return [Array<String>]
46
- #
47
- # @api public
48
- # @version 0.12.0
49
- def type_aliases
50
- __type_aliases__.keys
51
- end
52
-
53
- # @param alias_name [String, Symbol]
54
- # @param type [Any]
55
- # @return [void]
56
- #
57
- # @api public
58
- # @version 0.12.0
59
- def type_alias(alias_name, type)
60
- __type_aliases__.associate(alias_name, type)
61
- end
62
-
63
- # @param alias_name [String, Symbol]
64
- # @return [Any]
65
- #
66
- # @api public
67
- # @version 0.12.0
68
- def type_from_alias(alias_name)
69
- __type_aliases__.resolve(alias_name)
70
- end
71
- end
72
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @abstract
4
- # @api private
5
- # @since 0.12.0
6
- class SmartCore::Schema::TypeSystem::Interop::Operation
7
- # @param type [Any]
8
- # @return [void]
9
- #
10
- # @api private
11
- # @since 0.12.0
12
- def initialize(type)
13
- @type = type
14
- end
15
-
16
- # @param value [Any]
17
- # @return [Any]
18
- #
19
- # @api private
20
- # @since 0.12.0
21
- def call(value); end
22
-
23
- private
24
-
25
- # @return [Any]
26
- #
27
- # @api private
28
- # @since 0.12.0
29
- attr_reader :type
30
- end
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @abstract
4
- # @api private
5
- # @since 0.12.0
6
- class SmartCore::Schema::TypeSystem::Interop
7
- require_relative 'interop/operation'
8
- require_relative 'interop/abstract_factory'
9
- require_relative 'interop/aliasing'
10
-
11
- # @since 0.12.0
12
- include SmartCore::Schema::TypeSystem::Interop::Aliasing
13
-
14
- class << self
15
- # @param type_object [Any]
16
- # @return [SmartCore::Schema::TypeSystem::Interop]
17
- #
18
- # @api private
19
- # @since 0.12.0
20
- def create(type_object)
21
- self::AbstractFactory.create(type_object)
22
- end
23
-
24
- # @return [SmartCore::Schema::TypeSystem::Interop]
25
- #
26
- # @api private
27
- # @since 0.12.0
28
- def generic_type_object
29
- self::AbstractFactory.generic_type_object
30
- end
31
-
32
- # @param type_object [Any]
33
- # @return [void]
34
- #
35
- # @raise [SmartCore::Schema::IncorrectTypeObjectError]
36
- #
37
- # @api private
38
- # @since 0.12.0
39
- def prevent_incompatible_type!(type_object)
40
- self::AbstractFactory.prevent_incompatible_type!(type_object)
41
- end
42
-
43
- # @return [Any]
44
- #
45
- # @api private
46
- # @since 0.12.0
47
- def primitive_type_class
48
- self::AbstractFactory.primitive_type_class
49
- end
50
- end
51
-
52
- # @return [String]
53
- #
54
- # @api private
55
- # @since 0.5.1
56
- attr_reader :identifier
57
-
58
- # @param identifier [String]
59
- # @param valid_op [SmartCore::Schema::TypeSystem::Interop::Operation]
60
- # @param validate_op [SmartCore::Schema::TypeSystem::Interop::Operation]
61
- # @param cast_op [SmartCore::Schema::TypeSystem::Interop::Operation]
62
- # @return [void]
63
- #
64
- # @api private
65
- # @since 0.12.0
66
- # @version 0.5.1
67
- def initialize(identifier, valid_op, validate_op, cast_op)
68
- @identifier = identifier
69
- @valid_op = valid_op
70
- @validate_op = validate_op
71
- @cast_op = cast_op
72
- end
73
-
74
- # @param value [Any]
75
- # @return [Boolean]
76
- #
77
- # @api private
78
- # @since 0.12.0
79
- def valid?(value)
80
- valid_op.call(value)
81
- end
82
-
83
- # @param value [Any]
84
- # @return [void]
85
- #
86
- # @api private
87
- # @since 0.12.0
88
- def validate!(value)
89
- validate_op.call(value)
90
- end
91
-
92
- # @param value [Any]
93
- # @return [Any]
94
- #
95
- # @api private
96
- # @since 0.12.0
97
- def cast(value)
98
- cast_op.call(value)
99
- end
100
-
101
- private
102
-
103
- # @return [SmartCore::Schema::TypeSystem::Interop::Operation]
104
- #
105
- # @api private
106
- # @since 0.12.0
107
- attr_reader :valid_op
108
-
109
- # @return [SmartCore::Schema::TypeSystem::Interop::Operation]
110
- #
111
- # @api private
112
- # @since 0.12.0
113
- attr_reader :validate_op
114
-
115
- # @return [SmartCore::Schema::TypeSystem::Interop::Operation]
116
- #
117
- # @api private
118
- # @since 0.12.0
119
- attr_reader :cast_op
120
- end
@@ -1,162 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.12.0
5
- class SmartCore::Schema::TypeSystem::Registry
6
- include Enumerable
7
-
8
- # @return [void]
9
- #
10
- # @api private
11
- # @since 0.12.0
12
- def initialize
13
- @systems = {}
14
- @lock = SmartCore::Engine::ReadWriteLock.new
15
- end
16
-
17
- # @param system_identifier [String, Symbol]
18
- # @param interop_klass [Class<SmartCore::Schema::TypeSystem::Interop>]
19
- # @return [void]
20
- #
21
- # @api private
22
- # @since 0.12.0
23
- def register(system_identifier, interop_klass)
24
- @lock.write_sync { apply(system_identifier, interop_klass) }
25
- end
26
-
27
- # @param system_identifier [String, Symbol]
28
- # @return [Class<SmartCore::Schema::TypeSystem::Interop>]
29
- #
30
- # @api private
31
- # @since 0.12.0
32
- def resolve(system_identifier)
33
- @lock.read_sync { fetch(system_identifier) }
34
- end
35
-
36
- # @return [Array<String>]
37
- #
38
- # @api private
39
- # @since 0.12.0
40
- def names
41
- @lock.read_sync { system_names }
42
- end
43
-
44
- # @return [Array<Class<SmartCore::Schema::TypeSystem::Interop>>]
45
- #
46
- # @api private
47
- # @since 0.12.0
48
- def interops
49
- @lock.read_sync { system_interops }
50
- end
51
-
52
- # @param block [Block]
53
- # @yield [system_name, system_interop]
54
- # @yieldparam system_name [String]
55
- # @yieldparam system_interop [Class<SmartCore::Schema::TypeSystem::Interop>]
56
- # @return [Enumerable]
57
- #
58
- # @api private
59
- # @since 0.12.0
60
- def each(&block)
61
- @lock.read_sync { iterate(&block) }
62
- end
63
-
64
- # @return [Hash<String,Class<SmartCore::Schema::TypeSystem::Interop>]
65
- #
66
- # @api private
67
- # @since 0.12.0
68
- def to_h
69
- @lock.write_sync { systems.dup }
70
- end
71
- alias_method :to_hash, :to_h
72
-
73
- private
74
-
75
- # @return [Hash<String,Class<SmartCore::Schema::TypeSystem::Interop>]
76
- #
77
- # @api private
78
- # @since 0.12.0
79
- attr_reader :systems
80
-
81
- # @return [Array<String>]
82
- #
83
- # @pai private
84
- def system_names
85
- systems.keys
86
- end
87
-
88
- # @return [Array<Class<SmartCore::Schema::TypeSystem::Interop>>]
89
- #
90
- # @api private
91
- # @since 0.12.0
92
- def system_interops
93
- systems.values
94
- end
95
-
96
- # @param block [Block]
97
- # @yield [system_name, system_interop]
98
- # @yieldparam system_name [String]
99
- # @yieldparam system_interop [Class<SmartCore::Schema::TypeSystem::Interop>]
100
- # @return [Enumerable]
101
- #
102
- # @api private
103
- # @since 0.12.0
104
- def iterate(&block)
105
- block_given? ? systems.each_pair(&block) : systems.each_pair
106
- end
107
-
108
- # @param system_identifier [String, Symbol]
109
- # @param interop_klass [Class<SmartCore::Schema::TypeSystem::Interop>]
110
- # @return [void]
111
- #
112
- # @api private
113
- # @since 0.12.0
114
- def apply(system_identifier, interop_klass)
115
- prevent_incorrect_system_interop!(interop_klass)
116
- identifier = indifferently_accessible_identifier(system_identifier)
117
- systems[identifier] = interop_klass
118
- end
119
-
120
- # @param system_identifier [String, Symbol]
121
- # @return [Class<SmartCore::Schema::TypeSystem::Interop>]
122
- #
123
- # @raise [SmartCore::Schema::UnsupportedTypeSystemError]
124
- #
125
- # @api private
126
- # @since 0.12.0
127
- def fetch(system_identifier)
128
- identifier = indifferently_accessible_identifier(system_identifier)
129
-
130
- raise(
131
- SmartCore::Schema::UnsupportedTypeSystemError,
132
- "`#{identifier}` type system is not supported."
133
- ) unless systems.key?(identifier)
134
-
135
- systems.fetch(identifier)
136
- end
137
-
138
- # @param interop_klass [Class<SMartCore::Schema::TypeSystem::Interop>]
139
- # @return [void]
140
- #
141
- # @raise [SmartCore::Schema::IncorrectTypeSystemInteropError]
142
- #
143
- # @api private
144
- # @since 0.12.0
145
- def prevent_incorrect_system_interop!(interop_klass)
146
- unless interop_klass.is_a?(Class) && interop_klass < SmartCore::Schema::TypeSystem::Interop
147
- raise(
148
- SmartCore::Schema::IncorrectTypeSystemInteropError,
149
- 'Incorrect type system interop class.'
150
- )
151
- end
152
- end
153
-
154
- # @param system_identifier [String, Symbol]
155
- # @return [String]
156
- #
157
- # @api private
158
- # @since 0.12.0
159
- def indifferently_accessible_identifier(system_identifier)
160
- system_identifier.to_s.clone.tap(&:freeze)
161
- end
162
- end
@@ -1,87 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.12.0
5
- module SmartCore::Schema::TypeSystem::RegistryInterface
6
- class << self
7
- # @param base_module [Class, Module]
8
- # @return [void]
9
- #
10
- # @api private
11
- # @since 0.12.0
12
- def extended(base_module)
13
- base_module.instance_variable_set(
14
- :@registry, SmartCore::Schema::TypeSystem::Registry.new
15
- )
16
- base_module.instance_variable_set(
17
- :@access_lock, SmartCore::Engine::ReadWriteLock.new
18
- )
19
- end
20
- end
21
-
22
- # @option system_identifier [String, Symbol]
23
- # @option type [Any]
24
- # @return [SmartCore::Schema::TypeSystem::Interop]
25
- #
26
- # @api private
27
- # @since 0.12.0
28
- def build_interop(system: system_identifier, type: type_object)
29
- @access_lock.read_sync { registry.resolve(system_identifier).create(type_object) }
30
- end
31
-
32
- # @param identifier [String, Symbol]
33
- # @param interop_klass [Class<SmartCore::Schema::TypeSystem::Interop>]
34
- # @return [void]
35
- #
36
- # @api private
37
- # @since 0.12.0
38
- def register(identifier, interop_klass)
39
- @access_lock.write_sync { registry.register(identifier, interop_klass) }
40
- end
41
-
42
- # @param identifier [String, Symbol]
43
- # @return [Class<SmartCore::Schema::TypeSystem::Interop>]
44
- #
45
- # @api private
46
- # @since 0.12.0
47
- def resolve(identifier)
48
- @access_lock.read_sync { registry.resolve(identifier) }
49
- end
50
- alias_method :[], :resolve
51
-
52
- # @return [Array<String>]
53
- #
54
- # @api public
55
- # @since 0.12.0
56
- def names
57
- @access_lock.read_sync { registry.names }
58
- end
59
-
60
- # @return [Array<Class<SmartCore::Schema::TypeSystem::Interop>>]
61
- #
62
- # @api public
63
- # @since 0.12.0
64
- def systems
65
- @access_lock.read_sync { registry.to_h }
66
- end
67
-
68
- # @param block [Block]
69
- # @yield [system_name, system_interop]
70
- # @yieldparam system_name [String]
71
- # @yieldparam system_interop [Class<SmartCore::Schema::TypeSystem::Interop>]
72
- # @return [Enumerable]
73
- #
74
- # @api public
75
- # @since 0.12.0
76
- def each(&block)
77
- @access_lock.read_sync { registry.each(&block) }
78
- end
79
-
80
- private
81
-
82
- # @return [SmartCore::Schema::TypeSystem::Registry]
83
- #
84
- # @api private
85
- # @since 0.12.0
86
- attr_reader :registry
87
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SmartCore::Schema::TypeSystem
4
- # @api private
5
- # @since 0.12.0
6
- class SmartTypes::AbstractFactory < Interop::AbstractFactory
7
- class << self
8
- # @param type [SmartCore::Types::Primitive]
9
- # @return [void]
10
- #
11
- # @raise [SmartCore::Schema::IncorrectTypeObjectError]
12
- #
13
- # @api private
14
- # @since 0.12.0
15
- def prevent_incompatible_type!(type)
16
- unless type.is_a?(SmartCore::Types::Primitive)
17
- raise(
18
- SmartCore::Schema::IncorrectTypeObjectError,
19
- 'Incorrect SmartCore::Types primitive ' \
20
- '(type object should be a type of SmartCore::Types::Primitive)'
21
- )
22
- end
23
- end
24
-
25
- # @param type [Any]
26
- # @return [String]
27
- #
28
- # @api private
29
- # @since 0.12.0
30
- def build_identifier(type)
31
- type.name
32
- end
33
-
34
- # @param type [SmartCore::Types::Primitive]
35
- # @return [SmartCore::Schema::TypeSystem::SmartTypes::Operation::Valid]
36
- #
37
- # @api private
38
- # @since 0.12.0
39
- def build_valid_operation(type)
40
- SmartTypes::Operation::Valid.new(type)
41
- end
42
-
43
- # @return [SmartCore::Types::Value::Any]
44
- #
45
- # @api private
46
- # @since 0.12.0
47
- def generic_type_object
48
- SmartCore::Types::Value::Any
49
- end
50
-
51
- # @return [SmartCore::Types::Primitive]
52
- #
53
- # @api private
54
- # @since 0.12.0
55
- def primitive_type_class
56
- SmartCore::Types::Primitive
57
- end
58
-
59
- # @param type [SmartCore::Types::Primitive]
60
- # @return [SmartCore::Schema::TypeSystem::SmartTypes::Operation::Validate]
61
- #
62
- # @api private
63
- # @since 0.12.0
64
- def build_validate_operation(type)
65
- SmartTypes::Operation::Validate.new(type)
66
- end
67
-
68
- # @param type [SmartCore::Types::Primitive]
69
- # @return [SmartCore::Schema::TypeSystem::SmartTypes::Operation::Cast]
70
- #
71
- # @api private
72
- # @since 0.12.0
73
- def build_cast_operation(type)
74
- SmartTypes::Operation::Cast.new(type)
75
- end
76
-
77
- # @param identifier [String]
78
- # @param valid_op [SmartCore::Schema::TypeSystem::SmartTypes::Operation::Valid]
79
- # @param valid_op [SmartCore::Schema::TypeSystem::SmartTypes::Operation::Validate]
80
- # @param valid_op [SmartCore::Schema::TypeSystem::SmartTypes::Operation::Cast]
81
- # @return [SmartCore::Schema::TypeSystem::SmartTypes]
82
- #
83
- # @api private
84
- # @since 0.12.0
85
- # @version 0.5.1
86
- def build_interop(identifier, valid_op, validate_op, cast_op)
87
- SmartTypes.new(identifier, valid_op, validate_op, cast_op)
88
- end
89
- end
90
- end
91
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SmartCore::Schema::TypeSystem
4
- # @api private
5
- # @since 0.12.0
6
- class SmartTypes::Operation::Base < Interop::Operation
7
- end
8
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SmartCore::Schema::TypeSystem::SmartTypes::Operation
4
- # @api private
5
- # @since 0.12.0
6
- class Cast < Base
7
- # @param value [Any]
8
- # @return [Any]
9
- #
10
- # @api private
11
- # @since 0.12.0
12
- def call(value)
13
- type.cast(value)
14
- end
15
- end
16
- end