smart_types 0.1.0.alpha4 → 0.1.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cf6671b5ed2aa8bc547ce1efce8ec61ea44c7e800ddec0a28424d38097f6113
|
4
|
+
data.tar.gz: 5dd3e4e7203652b353133b1c8ba9795b5623c7ec329801a2417b4d24c40a97bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ebf37ceefbb4f96985e0e252b8bebf6a9c07e6d730e2c85cb065dd72cfec4473c012e6a4a1da846633e85a4701fcbeeaf57a13f97de21d6f7bc0a8d2c817ce2
|
7
|
+
data.tar.gz: d0318bc8233d6deca43d6b2d9cce852961385cbfbb2bc8c78c87a36e02fb45b9eed6c559a4605da1debef47d407bd4454f16aa4492f5b2e64255ed45214cca48
|
@@ -17,7 +17,7 @@ class SmartCore::Types::Primitive::Factory
|
|
17
17
|
type_definitions = build_type_definitions(type_definition)
|
18
18
|
type_checker = build_type_checker(type_definitions)
|
19
19
|
type_caster = build_type_caster(type_definitions)
|
20
|
-
type = build_type(type_category, type_checker, type_caster)
|
20
|
+
type = build_type(type_category, type_name, type_checker, type_caster)
|
21
21
|
type.tap { register_new_type(type_category, type_name, type) }
|
22
22
|
end
|
23
23
|
|
@@ -65,14 +65,15 @@ class SmartCore::Types::Primitive::Factory
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# @param type_klass [Class<SmartCore::Types::Primitive>]
|
68
|
+
# @param type_name [String, Symbol]
|
68
69
|
# @param type_checker [SmartCore::Types::Primitive::Checker]
|
69
70
|
# @param type_caster [SmartCore::Types::Primitive::Caster]
|
70
71
|
# @return [SmartCore::Types::Primitive]
|
71
72
|
#
|
72
73
|
# @api private
|
73
74
|
# @since 0.1.0
|
74
|
-
def build_type(type_category, type_checker, type_caster)
|
75
|
-
Class.new(type_category).new(type_checker, type_caster)
|
75
|
+
def build_type(type_category, type_name, type_checker, type_caster)
|
76
|
+
Class.new(type_category).new(type_checker, type_caster, type_name.to_s)
|
76
77
|
end
|
77
78
|
|
78
79
|
# @param type_category [Class<SmartCore::Types::Primitive>]
|
@@ -29,18 +29,25 @@ 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
|
+
|
32
38
|
# @param checker [SmartCore::Types::Primitive::Checker]
|
33
39
|
# @param caster [SmartCore::Types::Primitive::Caster]
|
34
|
-
# @param
|
40
|
+
# @param name [String]
|
35
41
|
# @return [void]
|
36
42
|
#
|
37
43
|
# @api private
|
38
44
|
# @since 0.1.0
|
39
|
-
def initialize(checker, caster)
|
45
|
+
def initialize(checker, caster, name)
|
40
46
|
@lock = SmartCore::Engine::Lock.new
|
41
47
|
@checker = checker
|
42
48
|
@caster = caster
|
43
49
|
@nilable = nil
|
50
|
+
@name = name.freeze
|
44
51
|
end
|
45
52
|
|
46
53
|
# @param value [Any]
|
@@ -60,7 +67,7 @@ class SmartCore::Types::Primitive
|
|
60
67
|
# @since 0.1.0
|
61
68
|
def validate!(value)
|
62
69
|
valid?(value) || raise(SmartCore::Types::TypeError, <<~ERROR_MESSAGE)
|
63
|
-
Invalid type (given #{value.
|
70
|
+
Invalid type (given #{(class << value; superclass; end).name}, expects #{name}/SmartCore)
|
64
71
|
ERROR_MESSAGE
|
65
72
|
end
|
66
73
|
|