primalize 0.3.8 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/primalize/single.rb +19 -1
- data/lib/primalize/version.rb +1 -1
- data/primalize.gemspec +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ff19c0f79e07c4d94f4e5eaee9ee618d5275b2da34acc0c5bbb25968066ca98
|
4
|
+
data.tar.gz: d234c055bfe364356c6b4438ea4f3f247bb10b94a2c0b8803ba60b8e1492d13c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdeea26a6076ebc89d58824b1e06afaf44b3732e2bfa0e039035464a6be8b2a8327fd443ee2b9151fb27b71245660cf58a38cfbab73d47db191f7a4091b91871
|
7
|
+
data.tar.gz: 0d6a9acbb0689a23430ce074abc7626ee934d1d02937853c02dc44fac3353bf70635426e3703366f7735411e19fb3f23b0b7050c55d1906022b507942e905150
|
data/lib/primalize/single.rb
CHANGED
@@ -10,7 +10,7 @@ module Primalize
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
def attributes **attrs
|
13
|
-
_attributes attrs
|
13
|
+
_attributes **attrs
|
14
14
|
end
|
15
15
|
|
16
16
|
def _attributes **attrs
|
@@ -378,6 +378,24 @@ module Primalize
|
|
378
378
|
def inspect
|
379
379
|
"optional(#{@types.map(&:inspect).join(', ')})"
|
380
380
|
end
|
381
|
+
|
382
|
+
def coerce value
|
383
|
+
if value.nil?
|
384
|
+
super
|
385
|
+
else
|
386
|
+
type = @types.find { |type| type === value }
|
387
|
+
|
388
|
+
if type.respond_to? :coerce
|
389
|
+
if @coercion
|
390
|
+
@coercion.call(value)
|
391
|
+
else
|
392
|
+
type.coerce(value)
|
393
|
+
end
|
394
|
+
else
|
395
|
+
value
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
381
399
|
end
|
382
400
|
|
383
401
|
class Any
|
data/lib/primalize/version.rb
CHANGED
data/primalize.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
26
|
spec.add_development_dependency "pry"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Gaskins
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- jgaskins@gmail.com
|
72
72
|
executables: []
|
@@ -92,7 +92,7 @@ homepage: https://github.com/jgaskins/primalize
|
|
92
92
|
licenses:
|
93
93
|
- MIT
|
94
94
|
metadata: {}
|
95
|
-
post_install_message:
|
95
|
+
post_install_message:
|
96
96
|
rdoc_options: []
|
97
97
|
require_paths:
|
98
98
|
- lib
|
@@ -107,8 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
110
|
+
rubygems_version: 3.3.7
|
111
|
+
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Type-checked serializers for your Ruby objects
|
114
114
|
test_files: []
|