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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cf6671b5ed2aa8bc547ce1efce8ec61ea44c7e800ddec0a28424d38097f6113
4
- data.tar.gz: 5dd3e4e7203652b353133b1c8ba9795b5623c7ec329801a2417b4d24c40a97bd
3
+ metadata.gz: d7ed742470e7ce794fc75f9e90e9e4b6eaa705658ab15404416f38798fc43822
4
+ data.tar.gz: e5cf9c4b207739ca7bc09ae46708b00676a2adb60a71cc679391238cbc696d4b
5
5
  SHA512:
6
- metadata.gz: 8ebf37ceefbb4f96985e0e252b8bebf6a9c07e6d730e2c85cb065dd72cfec4473c012e6a4a1da846633e85a4701fcbeeaf57a13f97de21d6f7bc0a8d2c817ce2
7
- data.tar.gz: d0318bc8233d6deca43d6b2d9cce852961385cbfbb2bc8c78c87a36e02fb45b9eed6c559a4605da1debef47d407bd4454f16aa4492f5b2e64255ed45214cca48
6
+ metadata.gz: 957613e5f2b4d3adde721c39c35ad4b934f74463812768e232a0496313a0fdbe9e1a1cf335b4184adc7e14473bce5a062fd2c2e553834ac964381ae435c2fc9b
7
+ data.tar.gz: 77ab18057ad5a66326a911caca44b19446cfe97f5bf961bf92e2efcecc109dbfbc45d4d7bfb70bdf83002eddffd6ca4b16631270d77cf2015b2ca990de229fbe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_types (0.1.0.alpha3)
4
+ smart_types (0.1.0.alpha5)
5
5
  smart_engine (~> 0.5)
6
6
 
7
7
  GEM
@@ -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, name)
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
- @name = name.freeze
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) || raise(SmartCore::Types::TypeError, <<~ERROR_MESSAGE)
70
- Invalid type (given #{(class << value; superclass; end).name}, expects #{name}/SmartCore)
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, type_name.to_s)
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 type_checler [SmartCore::Types::Primitive::NilableChecker]
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) }
@@ -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.alpha5'
10
+ VERSION = '0.1.0.alpha6'
11
11
  end
12
12
  end
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.alpha5
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-25 00:00:00.000000000 Z
11
+ date: 2020-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_engine