smart_types 0.1.0.alpha5 → 0.1.0.alpha6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/smart_core/types/primitive.rb +21 -10
- data/lib/smart_core/types/primitive/factory.rb +1 -1
- data/lib/smart_core/types/primitive/nilable_factory.rb +1 -1
- data/lib/smart_core/types/value/text.rb +1 -2
- data/lib/smart_core/types/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7ed742470e7ce794fc75f9e90e9e4b6eaa705658ab15404416f38798fc43822
|
4
|
+
data.tar.gz: e5cf9c4b207739ca7bc09ae46708b00676a2adb60a71cc679391238cbc696d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 957613e5f2b4d3adde721c39c35ad4b934f74463812768e232a0496313a0fdbe9e1a1cf335b4184adc7e14473bce5a062fd2c2e553834ac964381ae435c2fc9b
|
7
|
+
data.tar.gz: 77ab18057ad5a66326a911caca44b19446cfe97f5bf961bf92e2efcecc109dbfbc45d4d7bfb70bdf83002eddffd6ca4b16631270d77cf2015b2ca990de229fbe
|
data/Gemfile.lock
CHANGED
@@ -29,12 +29,6 @@ class SmartCore::Types::Primitive
|
|
29
29
|
# @since 0.1.0
|
30
30
|
attr_reader :caster
|
31
31
|
|
32
|
-
# @return [String]
|
33
|
-
#
|
34
|
-
# @api private
|
35
|
-
# @since 0.1.0
|
36
|
-
attr_reader :name
|
37
|
-
|
38
32
|
# @param checker [SmartCore::Types::Primitive::Checker]
|
39
33
|
# @param caster [SmartCore::Types::Primitive::Caster]
|
40
34
|
# @param name [String]
|
@@ -42,12 +36,19 @@ class SmartCore::Types::Primitive
|
|
42
36
|
#
|
43
37
|
# @api private
|
44
38
|
# @since 0.1.0
|
45
|
-
def initialize(checker, caster
|
39
|
+
def initialize(checker, caster)
|
46
40
|
@lock = SmartCore::Engine::Lock.new
|
47
41
|
@checker = checker
|
48
42
|
@caster = caster
|
49
43
|
@nilable = nil
|
50
|
-
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [String]
|
47
|
+
#
|
48
|
+
# @api public
|
49
|
+
# @since 0.1.0
|
50
|
+
def name
|
51
|
+
self.class.name
|
51
52
|
end
|
52
53
|
|
53
54
|
# @param value [Any]
|
@@ -66,8 +67,18 @@ class SmartCore::Types::Primitive
|
|
66
67
|
# @api public
|
67
68
|
# @since 0.1.0
|
68
69
|
def validate!(value)
|
69
|
-
valid?(value)
|
70
|
-
|
70
|
+
return if valid?(value)
|
71
|
+
|
72
|
+
# rubocop:disable Layout/RescueEnsureAlignment
|
73
|
+
value_type = begin
|
74
|
+
value.class.name
|
75
|
+
rescue NoMethodError
|
76
|
+
(class << value; superclass; end).name
|
77
|
+
end
|
78
|
+
# rubocop:enable Layout/RescueEnsureAlignment
|
79
|
+
|
80
|
+
raise(SmartCore::Types::TypeError, <<~ERROR_MESSAGE)
|
81
|
+
Invalid type (given #{value_type}, expects #{self.class.name}/SmartCore)
|
71
82
|
ERROR_MESSAGE
|
72
83
|
end
|
73
84
|
|
@@ -73,7 +73,7 @@ class SmartCore::Types::Primitive::Factory
|
|
73
73
|
# @api private
|
74
74
|
# @since 0.1.0
|
75
75
|
def build_type(type_category, type_name, type_checker, type_caster)
|
76
|
-
Class.new(type_category).new(type_checker, type_caster
|
76
|
+
Class.new(type_category).new(type_checker, type_caster)
|
77
77
|
end
|
78
78
|
|
79
79
|
# @param type_category [Class<SmartCore::Types::Primitive>]
|
@@ -36,7 +36,7 @@ module SmartCore::Types::Primitive::NilableFactory
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# @param type [SmartCore::Types::Primitive]
|
39
|
-
# @param
|
39
|
+
# @param type_checker [SmartCore::Types::Primitive::NilableChecker]
|
40
40
|
# @param type_caster [SmartCore::Types::Caster]
|
41
41
|
# @return [SmartCore::Type::Primitive]
|
42
42
|
#
|
@@ -3,6 +3,5 @@
|
|
3
3
|
# @api public
|
4
4
|
# @since 0.1.0
|
5
5
|
SmartCore::Types::Value::Text = SmartCore::Types::System.type_sum(
|
6
|
-
SmartCore::Types::Value::String,
|
7
|
-
SmartCore::Types::Value::Symbol
|
6
|
+
SmartCore::Types::Value::String, SmartCore::Types::Value::Symbol
|
8
7
|
) { |type| type.define_caster(&:to_s) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.alpha6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smart_engine
|