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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7101807266c034e1d5589679851992999ca6fc62e779aaf4f13b702952d4979
4
- data.tar.gz: d73173a994243b0697a1b417df4511f2deaa39796c0025bb1206ef1609327722
3
+ metadata.gz: 6ff19c0f79e07c4d94f4e5eaee9ee618d5275b2da34acc0c5bbb25968066ca98
4
+ data.tar.gz: d234c055bfe364356c6b4438ea4f3f247bb10b94a2c0b8803ba60b8e1492d13c
5
5
  SHA512:
6
- metadata.gz: afa0665df3f85fa9e031f6ec7cba2e5068e0d0a88b9f6eff52bc892a7a01e6d3c2c5837e39a0bcac3e42b89ad30ee27c1f4ffa617796fa4112905d4fddeb6f8d
7
- data.tar.gz: a0f95280e746a0991cbd8d6ce0fde84b563720e44ad008273138d605dcde3dd6a7465efa1041404020653f1d531add6f2a7dd73e5190e82719a6a3c232f24dda
6
+ metadata.gz: cdeea26a6076ebc89d58824b1e06afaf44b3732e2bfa0e039035464a6be8b2a8327fd443ee2b9151fb27b71245660cf58a38cfbab73d47db191f7a4091b91871
7
+ data.tar.gz: 0d6a9acbb0689a23430ce074abc7626ee934d1d02937853c02dc44fac3353bf70635426e3703366f7735411e19fb3f23b0b7050c55d1906022b507942e905150
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Primalize
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.10"
3
3
  end
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", "~> 1.16.a"
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.8
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: 2019-06-07 00:00:00.000000000 Z
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: 1.16.a
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: 1.16.a
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.0.2
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: []