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: 38c9d0410b4668ba347f5da8a6f76179406a96c53fa7af953cb21204f6c93a84
4
- data.tar.gz: ace2638b907add7049712113a67ad18ea277694c0335fceb3c0172d3056b6250
3
+ metadata.gz: 7cf6671b5ed2aa8bc547ce1efce8ec61ea44c7e800ddec0a28424d38097f6113
4
+ data.tar.gz: 5dd3e4e7203652b353133b1c8ba9795b5623c7ec329801a2417b4d24c40a97bd
5
5
  SHA512:
6
- metadata.gz: c6019665e9da02262c097c9326f7e8e72ad698563dfe8e5bb2f45bf6cb0ea8f31ab3f31b3524328fd99f7405b8171bbd49178021a1377af822d3d78d54cfb5e0
7
- data.tar.gz: 28d7b45311fb04413264ec5ecd628989391b796008547a633297cf50e5e58c404c41248ef519d229ebfa5f3f204b2f99e06fa1dc35559ab6f501222d5fd0018a
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 nilable [SmartCore::Types::Primitive]
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.class}, expects #{self}-related)
70
+ Invalid type (given #{(class << value; superclass; end).name}, expects #{name}/SmartCore)
64
71
  ERROR_MESSAGE
65
72
  end
66
73
 
@@ -7,6 +7,6 @@ module SmartCore
7
7
  # @api public
8
8
  # @since 0.1.0
9
9
  # @version 0.1.0
10
- VERSION = '0.1.0.alpha4'
10
+ VERSION = '0.1.0.alpha5'
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha4
4
+ version: 0.1.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov