dry-mutations 0.10.1 → 0.10.2

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
  SHA1:
3
- metadata.gz: 760fe6575962834c3d430912f8caf909a1fb110b
4
- data.tar.gz: 0de4a65993b087bcd3474f54f0a7633eb9a69148
3
+ metadata.gz: 0f80c93415873bc8756754a386cc570e876ce5bf
4
+ data.tar.gz: 7a9e9eb7334916480d10898b003fe81e06917d31
5
5
  SHA512:
6
- metadata.gz: 35a791a79e10cb3aadf1ea351359aa6e92f554b3bcd481a3d61615839fc00750487184f6ec4d58b930a6903630471e3323fe98a61bc9aef50b1858f9f8df79e7
7
- data.tar.gz: 6f42e471b03e94e146f8c273697808f080938a795ed75acdbe5c4e184faef00bb6a137d4777ce9078eb023adf64cdd1916c39d4000573bd9790dd7f4a4ef0135
6
+ metadata.gz: ce605855827a02da898e788fa79ba1d54fafbc29b5cb60d61d5062bf0740cb223d57279b08ec2a96c6fdc4e349af6c2fca4f38783b7d5d2269ef21e9656af64f
7
+ data.tar.gz: c8bd9287b5f3c8896f32009d5cba45a8c1b162df180490ae83aa9f57cedc4684af5f72980b1c4df0b7776d88344c3a4ea79c956305993a1a62950d9f3296a8de
data/lib/dry/mutations.rb CHANGED
@@ -16,6 +16,7 @@ require 'dry/mutations/transactions'
16
16
  require 'dry/mutations/schema'
17
17
 
18
18
  require 'dry/mutations/globals'
19
+ require 'dry/mutations/patches'
19
20
 
20
21
  module Dry
21
22
  # A dry implementation of mutations interface introduced by
@@ -0,0 +1,7 @@
1
+ Dry::Types::Sum::Constrained.prepend(Module.new do
2
+ def primitive
3
+ case
4
+ when [left, right].map(&:type).map(&:primitive) == [TrueClass, FalseClass] then ::Dry::Types['bool']
5
+ end
6
+ end
7
+ end)
@@ -56,12 +56,23 @@ module Dry
56
56
  ::Dry::Types['strict.date'], fn: ->(v) { v.is_a?(Date) ? v : (Date.parse(v.to_s) rescue v) }
57
57
  )
58
58
  when 'integer'
59
- :int?
60
- # FIXME: Why ints are not coercible?!
61
- #::Dry::Types::Constructor.new(
62
- # ::Dry::Types['coercible.int'], fn: ->(v) { v.is_a?(Integer) ? v : (v.to_i rescue v) }
63
- # )
64
- when 'boolean' then :bool?
59
+ ::Dry::Types::Constructor.new(
60
+ ::Dry::Types['strict.int'], fn: ->(v) { v.is_a?(Integer) ? v : (v.to_i rescue v) }
61
+ )
62
+ when 'boolean'
63
+ ::Dry::Types::Constructor.new(
64
+ ::Dry::Types['strict.bool'], fn: ->(v) do
65
+ case v
66
+ when TrueClass, FalseClass then v
67
+ when NilClass then false
68
+ when String
69
+ case
70
+ when Falsey?(v) then false
71
+ when Truthy?(v) then true
72
+ end
73
+ end
74
+ end
75
+ )
65
76
  else :"#{type}?"
66
77
  end
67
78
  end
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Mutations
3
- VERSION = '0.10.1'.freeze
3
+ VERSION = '0.10.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-mutations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksei Matiushkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-23 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -353,6 +353,7 @@ files:
353
353
  - lib/dry/mutations/extensions/outcome.rb
354
354
  - lib/dry/mutations/globals.rb
355
355
  - lib/dry/mutations/monkeypatches.rb
356
+ - lib/dry/mutations/patches.rb
356
357
  - lib/dry/mutations/predicates.rb
357
358
  - lib/dry/mutations/schema.rb
358
359
  - lib/dry/mutations/transactions.rb