smart_types 0.1.0.alpha3 → 0.1.0.alpha4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc4e623d3f8d313b11dbd7e483989b3f2b94904a9e3a1ec27edb85095fdc418b
4
- data.tar.gz: 3514c7ecfcd83963744f66ce92dfd648bd680b61ad34aaf4c2b0a9207cd842ad
3
+ metadata.gz: 38c9d0410b4668ba347f5da8a6f76179406a96c53fa7af953cb21204f6c93a84
4
+ data.tar.gz: ace2638b907add7049712113a67ad18ea277694c0335fceb3c0172d3056b6250
5
5
  SHA512:
6
- metadata.gz: a21d4a5a20575cba14a000440c6da87aab465b2aa7c02b2697f13c422fc3c6dbe873c4b2d0fcfec1e5ee182db7a356b8ca0f3bf7beae0f5787b10610d4a3bfca
7
- data.tar.gz: 80c82999c44edab7225b5169cbff0586254c5d817efbfb4c5df4f6906f0b794280dd52c7342fe732b30a6b339c96cf24b40d8c79915a679b87fca9e91a3ac6fa
6
+ metadata.gz: c6019665e9da02262c097c9326f7e8e72ad698563dfe8e5bb2f45bf6cb0ea8f31ab3f31b3524328fd99f7405b8171bbd49178021a1377af822d3d78d54cfb5e0
7
+ data.tar.gz: 28d7b45311fb04413264ec5ecd628989391b796008547a633297cf50e5e58c404c41248ef519d229ebfa5f3f204b2f99e06fa1dc35559ab6f501222d5fd0018a
data/README.md CHANGED
@@ -81,6 +81,14 @@ SmartCore::Types::Value::Module.nilable
81
81
 
82
82
  ---
83
83
 
84
+ ## Constrained types
85
+
86
+ ```ruby
87
+ # documentation is coming
88
+ ```
89
+
90
+ ---
91
+
84
92
  ## Type validation and type casting
85
93
 
86
94
  ```ruby
@@ -93,6 +101,17 @@ SmartCore::Types::Value::Module.nilable
93
101
 
94
102
  ```ruby
95
103
  # documentation is coming
104
+
105
+ # example:
106
+ SmartCore::Types::Value.define_type(:String) do |type|
107
+ type.define_checker do |value|
108
+ value.is_a?(::String)
109
+ end
110
+
111
+ type.define_caster do |value|
112
+ value.to_s
113
+ end
114
+ end
96
115
  ```
97
116
 
98
117
  ---
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ SmartCore::Types::Value.define_type(:Nil) do |type|
4
+ type.define_checker do |value|
5
+ # rubocop:disable Style/NilComparison
6
+ value == nil # NOTE: #nil? is not used cuz BasicObject has no #nil? method
7
+ # rubocop:enable Style/NilComparison
8
+ end
9
+ end
@@ -3,6 +3,7 @@
3
3
  # @api public
4
4
  # @since 0.1.0
5
5
  class SmartCore::Types::Value < SmartCore::Types::Primitive
6
+ require_relative 'value/nil'
6
7
  require_relative 'value/string'
7
8
  require_relative 'value/symbol'
8
9
  require_relative 'value/text'
@@ -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.alpha3'
10
+ VERSION = '0.1.0.alpha4'
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.alpha3
4
+ version: 0.1.0.alpha4
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-24 00:00:00.000000000 Z
11
+ date: 2020-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_engine
@@ -146,6 +146,7 @@ files:
146
146
  - lib/smart_core/types/value/hash.rb
147
147
  - lib/smart_core/types/value/integer.rb
148
148
  - lib/smart_core/types/value/module.rb
149
+ - lib/smart_core/types/value/nil.rb
149
150
  - lib/smart_core/types/value/numeric.rb
150
151
  - lib/smart_core/types/value/proc.rb
151
152
  - lib/smart_core/types/value/string.rb