strict 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/strict/interface.rb +4 -0
- data/lib/strict/interfaces/coercer.rb +19 -0
- data/lib/strict/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: ae43c882eaf20478716e5770eff835c3c9611b714f20ba98b23418969a40cb8f
|
4
|
+
data.tar.gz: b003e41e3b5efb4628e40c14dc84e4fdb64e8ab8c457a6299347d921ff4907bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c09fa26af6510b02c08c2cb7965f3ccb83703f0d5ca4c8a741516f09810e0069ed46bb69a6b5af0fec8effd105c6c0be49619a42c7ca5debacd5462391ebe9b4
|
7
|
+
data.tar.gz: 17d077e3ea3ed656a71ff3fed66c057c9f49468bcdbd66b3ea16c1d519a7a2ab2ff28973b4b98507035dce8367ebf5e7665772ced2eaec67e4cf300c6e69d320
|
data/Gemfile.lock
CHANGED
data/lib/strict/interface.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Strict
|
4
|
+
module Interfaces
|
5
|
+
class Coercer
|
6
|
+
attr_reader :interface_class
|
7
|
+
|
8
|
+
def initialize(interface_class)
|
9
|
+
@interface_class = interface_class
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(value)
|
13
|
+
return value if value.nil? || value.instance_of?(interface_class)
|
14
|
+
|
15
|
+
interface_class.new(value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/strict/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- lib/strict/implementation_does_not_conform_error.rb
|
171
171
|
- lib/strict/initialization_error.rb
|
172
172
|
- lib/strict/interface.rb
|
173
|
+
- lib/strict/interfaces/coercer.rb
|
173
174
|
- lib/strict/interfaces/instance.rb
|
174
175
|
- lib/strict/method.rb
|
175
176
|
- lib/strict/method_call_error.rb
|