mixture 0.3.6 → 0.4.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/mixture/coerce/class.rb +6 -0
- data/lib/mixture/coerce.rb +3 -1
- data/lib/mixture/types/class.rb +1 -1
- data/lib/mixture/types.rb +1 -1
- data/lib/mixture/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdcfd77ffa0853daa936e5a7e7c10d18dcc12bd6
|
4
|
+
data.tar.gz: acb4173454fe8c014f33d6b43f489f9cba7338f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb75c08641030b0c5acc22a1a51bc21cdb122fde7a3cdd5d8ffd6b19f1ae2014cf56bddc46cda61239c8c65baeb1e4ea2c2cf2f8c7cf6f5f5ac1ccd7f593ecc4
|
7
|
+
data.tar.gz: e425fa998b3198e7f9c43123a757700de9635063505c5ca6b588c58aecc6696d41ee1f48bdf70c7b781c47006f55e29d62bf406bf5d2abb0fafa947fb0a7ec75
|
data/Gemfile.lock
CHANGED
data/lib/mixture/coerce/class.rb
CHANGED
@@ -7,6 +7,12 @@ module Mixture
|
|
7
7
|
type Types::Class
|
8
8
|
|
9
9
|
coerce_to(Types::Object, Itself)
|
10
|
+
coerce_to(Types::Class) do |value, type|
|
11
|
+
member = type.options.fetch(:members).first
|
12
|
+
fail CoercionError, "Cannot coerce #{value.class} =>" \
|
13
|
+
" #{member}" unless value.is_a?(member)
|
14
|
+
value
|
15
|
+
end
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
data/lib/mixture/coerce.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
|
3
4
|
require "mixture/coerce/base"
|
4
|
-
require "mixture/coerce/date"
|
5
5
|
require "mixture/coerce/array"
|
6
|
+
require "mixture/coerce/class"
|
7
|
+
require "mixture/coerce/date"
|
6
8
|
require "mixture/coerce/datetime"
|
7
9
|
require "mixture/coerce/float"
|
8
10
|
require "mixture/coerce/hash"
|
data/lib/mixture/types/class.rb
CHANGED
data/lib/mixture/types.rb
CHANGED
@@ -93,8 +93,8 @@ require "mixture/types/access"
|
|
93
93
|
require "mixture/types/object"
|
94
94
|
require "mixture/types/enumerable"
|
95
95
|
require "mixture/types/collection"
|
96
|
-
require "mixture/types/class"
|
97
96
|
require "mixture/types/boolean"
|
97
|
+
require "mixture/types/class"
|
98
98
|
require "mixture/types/numeric"
|
99
99
|
require "mixture/types/array"
|
100
100
|
require "mixture/types/date"
|
data/lib/mixture/version.rb
CHANGED