smart_types 0.1.0.alpha3 → 0.1.0.alpha4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/lib/smart_core/types/value/nil.rb +9 -0
- data/lib/smart_core/types/value.rb +1 -0
- data/lib/smart_core/types/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c9d0410b4668ba347f5da8a6f76179406a96c53fa7af953cb21204f6c93a84
|
4
|
+
data.tar.gz: ace2638b907add7049712113a67ad18ea277694c0335fceb3c0172d3056b6250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.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-
|
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
|