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,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class SmartCore::Schema::Checker::Rules::Options
4
- # @api private
5
- # @since 0.1.0
6
- class Filled < Empty
7
- # @note Constant is used only for other developers.
8
- # @return [Symbol]
9
- #
10
- # @api private
11
- # @since 0.1.0
12
- ERROR_CODE = :non_filled
13
-
14
- # @param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash]
15
- # @return [SmartCore::Schema::Checker::Rules::Result::Success]
16
- # @return [SmartCore::Schema::Checker::Rules::Result::Failure]
17
- #
18
- # @api private
19
- # @since 0.1.0
20
- def validate(verifiable_hash)
21
- schema_value = verifiable_hash[schema_key]
22
-
23
- if non_filled?(schema_value)
24
- SmartCore::Schema::Checker::Rules::Result::Failure.new(
25
- key: schema_key,
26
- value: schema_value,
27
- error: ERROR_CODE,
28
- message: 'Requires to be filled'
29
- )
30
- else
31
- SmartCore::Schema::Checker::Rules::Result::Success.new(
32
- key: schema_key,
33
- value: schema_value
34
- )
35
- end
36
- end
37
-
38
- private
39
-
40
- # @param value [Any]
41
- # @return [Boolean]
42
- #
43
- # @api private
44
- # @since 0.1.0
45
- def non_filled?(value)
46
- value == nil
47
- end
48
- end
49
- end
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class SmartCore::Schema::Checker::Rules::Options
4
- # @api private
5
- # @since 0.1.0
6
- class Type < Empty
7
- # @note Constant is used only for clarity (for other developers)
8
- # @return [Symbol]
9
- #
10
- # @api private
11
- # @since 0.1.0
12
- ERROR_CODE = :invalid_type
13
-
14
- # @param rule [SmartCore::Schema::Checker::Rules::Base]
15
- # @param required_type [String, Symbol, SmartCore::Types::Primitive]
16
- # @return [void]
17
- #
18
- # @api private
19
- # @since 0.1.0
20
- def initialize(rule, required_type)
21
- super(rule)
22
- @type = resolve_required_type(required_type)
23
- end
24
-
25
- # @param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash]
26
- # @return [SmartCore::Schema::Checker::Rules::Result::Success]
27
- # @return [SmartCore::Schema::Checker::Rules::Result::Failure]
28
- #
29
- # @api private
30
- # @since 0.1.0
31
- def validate(verifiable_hash)
32
- schema_value = verifiable_hash[schema_key]
33
-
34
- if type.valid?(schema_value)
35
- SmartCore::Schema::Checker::Rules::Result::Success.new(
36
- key: schema_key,
37
- value: schema_value
38
- )
39
- else
40
- SmartCore::Schema::Checker::Rules::Result::Failure.new(
41
- key: schema_key,
42
- value: schema_value,
43
- error: ERROR_CODE,
44
- message: "Requires #{type} type (got: #{schema_value.class})"
45
- )
46
- end
47
- end
48
-
49
- private
50
-
51
- # @return [String, Symbol, SmartCore::Types::Primitive]
52
- #
53
- # @api private
54
- # @since 0.1.0
55
- attr_reader :type
56
-
57
- # @param required_type [String, Symbol, SmartCore::Types::Primitive]
58
- # @return [SmartCore::Types::Primitive]
59
- #
60
- # @api private
61
- # @since 0.1.0
62
- def resolve_required_type(required_type)
63
- unless required_type.is_a?(String) ||
64
- required_type.is_a?(Symbol) ||
65
- required_type.is_a?(SmartCore::Schema.type_system.primitive_type_class)
66
- raise(SmartCore::Schema::ArgumentError, <<~ERROR_MESSAGE)
67
- Schema key type should be a type of string, symbol or
68
- #{SmartCore::Schema.type_system.primitive_type_class.name} (got: #{required_type})
69
- ERROR_MESSAGE
70
- end
71
-
72
- if required_type.is_a?(SmartCore::Schema.type_system.primitive_type_class)
73
- required_type
74
- else
75
- begin
76
- SmartCore::Schema.type_system.type_from_alias(required_type)
77
- # SmartCore::Schema::Checker::Rules::TYPE_ALIASES.fetch(required_type.to_s)
78
- rescue KeyError
79
- raise(SmartCore::Schema::ArgumentError, <<~ERROR_MESSAGE)
80
- Chosen schema key type is not supported or not registered (got #{required_type})
81
- ERROR_MESSAGE
82
- end
83
- end
84
-
85
- # TODO: rework with smart_type-system
86
- end
87
- end
88
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- # @version 0.8.0
6
- class SmartCore::Schema::Checker::Rules::Options
7
- require_relative 'options/empty'
8
- require_relative 'options/type'
9
- require_relative 'options/filled'
10
-
11
- # @param rule [SmartCore::Schema::Checker::Rules::Base]
12
- # @return [void]
13
- #
14
- # @api private
15
- # @since 0.1.0
16
- def initialize(rule)
17
- @type = Empty.new(rule)
18
- @filled = Empty.new(rule)
19
- end
20
-
21
- # @return [SmartCore::Schema::Checker::Rules::Options::Type]
22
- # @return [SmartCore::Schema::Checker::Rules::Options::Empty]
23
- #
24
- # @api private
25
- # @since 0.1.0
26
- # @version 0.8.0
27
- def type
28
- @type
29
- end
30
-
31
- # @param option [SmartCore::Schema::Checker::Rules::Options::Type]
32
- # @return [void]
33
- #
34
- # @api private
35
- # @since 0.1.0
36
- # @version 0.8.0
37
- def type=(option)
38
- @type = option
39
- end
40
-
41
- # @return [SmartCore::Schema::Checker::Rules::Options::Filled]
42
- # @return [SmartCore::Schema::Checker::Rules::Options::Empty]
43
- #
44
- # @api private
45
- # @since 0.1.0
46
- # @version 0.8.0
47
- def filled
48
- @filled
49
- end
50
-
51
- # @param option [SmartCore::Schema::Checker::Rules::Options::Filled]
52
- # @return [void]
53
- #
54
- # @api private
55
- # @since 0.1.0
56
- # @version 0.8.0
57
- def filled=(option)
58
- @filled = option
59
- end
60
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- # @version 0.3.0
6
- class SmartCore::Schema::Checker::Rules::Required < SmartCore::Schema::Checker::Rules::Base
7
- # @return [SmartCore::Schema::Checker::Rules::Requirement::Required]
8
- #
9
- # @api private
10
- # @since 0.1.0
11
- attr_reader :requirement
12
-
13
- # @param root_reconciler [SmartCore::Schema::Checker::Reconciler]
14
- # @param schema_key [String, Symbol]
15
- # @param nested_definitions [Block]
16
- # @return [void]
17
- #
18
- # @api private
19
- # @since 0.1.0
20
- # @version 0.3.0
21
- # rubocop:disable Style/SuperArguments
22
- def initialize(root_reconciler, schema_key, &nested_definitions)
23
- super(root_reconciler, schema_key, &nested_definitions)
24
- @requirement = SmartCore::Schema::Checker::Rules::Requirement::Required.new(self)
25
- end
26
- # rubocop:enable Style/SuperArguments
27
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- class SmartCore::Schema::Checker::Rules::Requirement::Optional
6
- # @param rule [SmartCore::Schema::Checker::Rules::Optional]
7
- # @return [void]
8
- #
9
- # @api private
10
- # @since 0.1.0
11
- def initialize(rule)
12
- @rule = rule
13
- end
14
-
15
- # @param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash]
16
- # @return [SmartCore::Schema::Checker::Rules::Requirement::Result]
17
- #
18
- # @api private
19
- # @since 0.1.0
20
- def validate(verifiable_hash)
21
- SmartCore::Schema::Checker::Rules::Requirement::Result.new(
22
- rule.schema_key,
23
- verifiable_hash,
24
- required: false,
25
- key_exists: verifiable_hash.key?(rule.schema_key)
26
- )
27
- end
28
-
29
- private
30
-
31
- # @return [SmartCore::Schema::Checker::Rules::Required]
32
- #
33
- # @api private
34
- # @since 0.1.0
35
- attr_reader :rule
36
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- class SmartCore::Schema::Checker::Rules::Requirement::Required
6
- # @param rule [SmartCore::Schema::Checker::Rules::Required]
7
- # @return [void]
8
- #
9
- # @api private
10
- # @since 0.1.0
11
- def initialize(rule)
12
- @rule = rule
13
- end
14
-
15
- # @param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash]
16
- # @return [SmartCore::Schema::Checker::Rules::Requirement::Result]
17
- #
18
- # @api private
19
- # @since 0.1.0
20
- def validate(verifiable_hash)
21
- SmartCore::Schema::Checker::Rules::Requirement::Result.new(
22
- rule.schema_key,
23
- verifiable_hash,
24
- required: true,
25
- key_exists: verifiable_hash.key?(rule.schema_key)
26
- )
27
- end
28
-
29
- private
30
-
31
- # @return [SmartCore::Schema::Checker::Rules::Required]
32
- #
33
- # @api private
34
- # @since 0.1.0
35
- attr_reader :rule
36
- end
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- class SmartCore::Schema::Checker::Rules::Requirement::Result
6
- # @return [Symbol]
7
- #
8
- # @api private
9
- # @since 0.1.0
10
- ERROR_CODE = :required_key_not_found
11
-
12
- # @return [String]
13
- #
14
- # @api private
15
- # @since 0.1.0
16
- attr_reader :key
17
-
18
- # @return [SmartCore::Schema::Checker::VerifiableHash]
19
- #
20
- # @api private
21
- # @since 0.1.0
22
- attr_reader :verifiable_hash
23
-
24
- # @return [Symbol, NilClass]
25
- #
26
- # @api private
27
- # @since 0.1.0
28
- attr_reader :error
29
-
30
- # @return [String, NilClass]
31
- #
32
- # @api private
33
- # @since 0.1.0
34
- attr_reader :message
35
-
36
- # @param key [String]
37
- # @param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash]
38
- # @param required [Boolean]
39
- # @param key_exists [Boolean]
40
- # @return [void]
41
- #
42
- # @api private
43
- # @since 0.1.0
44
- def initialize(key, verifiable_hash, required:, key_exists:)
45
- @key = key
46
- @verifiable_hash = verifiable_hash
47
- @required = required
48
- @optional = !required
49
- @key_exists = key_exists
50
- @success = required ? key_exists : true
51
- @failure = required ? !key_exists : false
52
- @error = (required && !key_exists) ? ERROR_CODE : nil
53
- @message = (required && !key_exists) ? "Required key :#{key} not found" : nil
54
- end
55
-
56
- # @return [Boolean]
57
- #
58
- # @api private
59
- # @since 0.1.0
60
- def success?
61
- @success
62
- end
63
-
64
- # @return [Boolean]
65
- #
66
- # @api private
67
- # @since 0.1.0
68
- def failure?
69
- @failure
70
- end
71
-
72
- # @return [Boolean]
73
- #
74
- # @api private
75
- # @since 0.1.0
76
- def key_exists?
77
- @key_exists
78
- end
79
-
80
- # @return [Boolean]
81
- #
82
- # @api private
83
- # @since 0.1.0
84
- def optional?
85
- @optional
86
- end
87
-
88
- # @return [Boolean]
89
- #
90
- # @api private
91
- # @since 0.1.0
92
- def required?
93
- @required
94
- end
95
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- module SmartCore::Schema::Checker::Rules::Requirement
6
- require_relative 'requirement/result'
7
- require_relative 'requirement/required'
8
- require_relative 'requirement/optional'
9
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- class SmartCore::Schema::Checker::Rules::Result::Base
6
- # @return [String]
7
- #
8
- # @api public
9
- # @since 0.1.0
10
- attr_reader :key
11
-
12
- # @return [Any]
13
- #
14
- # @api public
15
- # @since 0.1.0
16
- attr_reader :value
17
-
18
- # @option key [String]
19
- # @option value [Any]
20
- # @return [void]
21
- #
22
- # @api private
23
- # @since 0.1.0
24
- def initialize(key:, value:)
25
- @key = key
26
- @value = value
27
- end
28
-
29
- # @return [Boolean]
30
- #
31
- # @api public
32
- # @since 0.1.0
33
- def success?
34
- false
35
- end
36
-
37
- # @return [Boolean]
38
- #
39
- # @api public
40
- # @since 0.1.0
41
- def failure?
42
- false
43
- end
44
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SmartCore::Schema::Checker::Rules::Result
4
- # @api private
5
- # @since 0.1.0
6
- class Failure < Base
7
- # @return [Symbol]
8
- #
9
- # @api public
10
- # @since 0.1.0
11
- attr_reader :error
12
-
13
- # @return [String]
14
- #
15
- # @api public
16
- # @since 0.1.0
17
- attr_reader :message
18
-
19
- # @option key [String]
20
- # @option value [Any]
21
- # @option error [Symbol]
22
- # @option message [String]
23
- # @return [void]
24
- #
25
- # @api private
26
- # @since 0.1.0
27
- def initialize(key:, value:, error:, message:)
28
- super(key: key, value: value)
29
- @error = error
30
- @message = message
31
- end
32
-
33
- # @return [Boolean]
34
- #
35
- # @api public
36
- # @since 0.1.0
37
- def failure?
38
- true
39
- end
40
- end
41
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SmartCore::Schema::Checker::Rules::Result
4
- # @api private
5
- # @since 0.1.0
6
- class Success < Base
7
- # @return [Boolean]
8
- #
9
- # @api public
10
- # @since 0.1.0
11
- def success?
12
- true
13
- end
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- module SmartCore::Schema::Checker::Rules::Result
6
- require_relative 'result/base'
7
- require_relative 'result/success'
8
- require_relative 'result/failure'
9
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- # rubocop:disable Style/StaticClass
6
- class SmartCore::Schema::Checker::Rules
7
- # @todo rework with smart_type-system
8
- # @note non-frized constant is used for temporary extendability
9
- # @return [SmartCore::Types::Primitive]
10
- #
11
- # @api private
12
- # @since 0.1.0
13
- # @version 0.2.0
14
- # rubocop:disable Style/MutableConstant
15
- TYPE_ALIASES = {
16
- 'value.any' => SmartCore::Types::Value::Any.nilable,
17
- 'value.nil' => SmartCore::Types::Value::Nil.nilable,
18
- 'value.string' => SmartCore::Types::Value::String.nilable,
19
- 'value.symbol' => SmartCore::Types::Value::Symbol.nilable,
20
- 'value.text' => SmartCore::Types::Value::Text.nilable,
21
- 'value.integer' => SmartCore::Types::Value::Integer.nilable,
22
- 'value.float' => SmartCore::Types::Value::Float.nilable,
23
- 'value.numeric' => SmartCore::Types::Value::Numeric.nilable,
24
- 'value.big_decimal' => SmartCore::Types::Value::BigDecimal.nilable,
25
- 'value.boolean' => SmartCore::Types::Value::Boolean.nilable,
26
- 'value.array' => SmartCore::Types::Value::Array.nilable,
27
- 'value.hash' => SmartCore::Types::Value::Hash.nilable,
28
- 'value.proc' => SmartCore::Types::Value::Proc.nilable,
29
- 'value.class' => SmartCore::Types::Value::Class.nilable,
30
- 'value.module' => SmartCore::Types::Value::Module.nilable,
31
- 'value.time' => SmartCore::Types::Value::Time.nilable,
32
- 'value.date_time' => SmartCore::Types::Value::DateTime.nilable,
33
- 'value.date' => SmartCore::Types::Value::Date.nilable,
34
- 'value.time_based' => SmartCore::Types::Value::TimeBased.nilable,
35
- 'any' => SmartCore::Types::Value::Any.nilable,
36
- 'nil' => SmartCore::Types::Value::Nil.nilable,
37
- 'string' => SmartCore::Types::Value::String.nilable,
38
- 'symbol' => SmartCore::Types::Value::Symbol.nilable,
39
- 'text' => SmartCore::Types::Value::Text.nilable,
40
- 'integer' => SmartCore::Types::Value::Integer.nilable,
41
- 'float' => SmartCore::Types::Value::Float.nilable,
42
- 'numeric' => SmartCore::Types::Value::Numeric.nilable,
43
- 'big_decimal' => SmartCore::Types::Value::BigDecimal.nilable,
44
- 'boolean' => SmartCore::Types::Value::Boolean.nilable,
45
- 'array' => SmartCore::Types::Value::Array.nilable,
46
- 'hash' => SmartCore::Types::Value::Hash.nilable,
47
- 'proc' => SmartCore::Types::Value::Proc.nilable,
48
- 'class' => SmartCore::Types::Value::Class.nilable,
49
- 'module' => SmartCore::Types::Value::Module.nilable,
50
- 'time' => SmartCore::Types::Value::Time.nilable,
51
- 'date_time' => SmartCore::Types::Value::DateTime.nilable,
52
- 'date' => SmartCore::Types::Value::Date.nilable,
53
- 'time_based' => SmartCore::Types::Value::TimeBased.nilable
54
- }
55
- # rubocop:enable Style/MutableConstant
56
- end
57
- # rubocop:enable Style/StaticClass
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- class SmartCore::Schema::Checker::Rules::Verifier::Result
6
- # @since 0.1.0
7
- include Enumerable
8
-
9
- # @return [Array<SmartCore::Schema::Checker::Rules::Result::Base>]
10
- #
11
- # @api private
12
- # @since 0.1.0
13
- attr_reader :results
14
-
15
- # @return [SmartCore::Schema::Checker::Rules::Base]
16
- #
17
- # @api private
18
- # @since 0.1.0
19
- attr_reader :rule
20
-
21
- # @return [void]
22
- #
23
- # @api private
24
- # @since 0.1.0
25
- def initialize(rule)
26
- @rule = rule
27
- @results = []
28
- end
29
-
30
- # @return [String]
31
- #
32
- # @api private
33
- # @since 0.1.0
34
- def key
35
- rule.schema_key
36
- end
37
-
38
- # @param result [SmartCore::Schema::Checker::Rules::Result::Base]
39
- # @return [result]
40
- #
41
- # @api private
42
- # @since 0.1.0
43
- def add(result)
44
- result.tap { results << result }
45
- end
46
- alias_method :<<, :add
47
-
48
- # @param block [Block]
49
- # @yield [result]
50
- # @yieldparam result [SmartCore::Schema::Checker::Rules::Result::Base]
51
- # @return [Enumerable]
52
- #
53
- # @api private
54
- # @since 0.1.0
55
- def each(&block)
56
- block_given? ? results.each(&block) : results.each
57
- end
58
- alias_method :each_result, :each
59
-
60
- # @return [Boolean]
61
- #
62
- # @api public
63
- # @since 0.1.0
64
- def success?
65
- results.all?(&:success?)
66
- end
67
-
68
- # @return [Boolean]
69
- #
70
- # @api public
71
- # @since 0.1.0
72
- def failure?
73
- results.all?(&:failure?)
74
- end
75
- end