virtus2 2.0.1 → 2.0.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
  SHA256:
3
- metadata.gz: 931b9a71f0f9c09c2b861371f2ad57a7553f005b0ddb5920674dd8c2d2df12a6
4
- data.tar.gz: 754af0ece66410668ceb1ea23c7a5aca49a9d7edf8c8fd4587e168c57369ff45
3
+ metadata.gz: 841ced82c04c9a17b904f15c9afbbe0ef833cea1a50b321adfdd613d146591e6
4
+ data.tar.gz: 24d8f67f1abdaa6a63b5b6e04a2088ce4ed55c1f37e63492ca4029a790f17e8e
5
5
  SHA512:
6
- metadata.gz: bf30cb66aa3fb3c507d9cc7dac83749b3f30dfb51d701cd1797015e847573123042779bfa7ace1b666b28b8fe8f7f99503a533ed73f21e5a8006c6b0ed119ed1
7
- data.tar.gz: 366a2a1989ffeaad24342f2c687835b4b48735cd7cd83916f2a8dfe6a8201c9397b931f03a2c64229c3dc00859607f5e421e597e15b93250ba737f3eedc0d021
6
+ metadata.gz: 77845a42756aa354f217ec353a422733121c13b3cada94d96b17576cabc2344980916933987338a4d7981f71e03483ef34a718a183eed54129e0acde47228b33
7
+ data.tar.gz: 0abf44bdcc8e443b8e86db4643e36c52d490f1fc5a7200b8683b0f1d0ab85f4ce5f5d4848e489855b0e6100dbb4355cdc2b0e2fb9b8fc6513d2fbf7e4c9b8c42
data/Changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ # v2.0.2 2021-09-30
2
+ * [fixed] Support for ActiveSupport's HashWithIndifferentAccess
3
+
1
4
  # v2.0.0 2021-06-07
2
5
 
3
6
  * [changed] min ruby version is now 2.0 (solnic)
@@ -29,7 +29,8 @@ module Virtus
29
29
  #
30
30
  # @api private
31
31
  def call(value)
32
- coercers[value.class].public_send(method, value)
32
+ call_method = (method == :to_hash && value.kind_of?(Hash)) ? :itself : method
33
+ coercers[value.class].public_send(call_method, value)
33
34
  rescue ::Coercible::UnsupportedCoercion
34
35
  value
35
36
  end
@@ -4,10 +4,6 @@ module Virtus
4
4
  class Attribute
5
5
 
6
6
  # Type to be used inside attributes as enums.
7
- # @example
8
- # class Event < Quiver::BaseModel
9
- # attribute :mode, Quiver::Types::Enum[:read, :write]
10
- # end
11
7
  class Enum < Attribute
12
8
 
13
9
  primitive Axiom::Types::Symbol
@@ -101,12 +101,13 @@ module Virtus
101
101
  # @see [Attribute#coerce]
102
102
  #
103
103
  # @api public
104
- def coerce(*)
104
+ def coerce(input)
105
105
  coerced = super
106
+ klass = input.kind_of?(::Hash) ? input.class : ::Hash
106
107
 
107
108
  return coerced unless coerced.respond_to?(:each_with_object)
108
109
 
109
- coerced.each_with_object({}) do |(key, value), hash|
110
+ coerced.each_with_object(klass.new) do |(key, value), hash|
110
111
  hash[key_type.coerce(key)] = value_type.coerce(value)
111
112
  end
112
113
  end
@@ -1,3 +1,3 @@
1
1
  module Virtus
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-15 00:00:00.000000000 Z
12
+ date: 2021-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: descendants_tracker
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  - !ruby/object:Gem::Version
219
219
  version: '0'
220
220
  requirements: []
221
- rubygems_version: 3.2.21
221
+ rubygems_version: 3.0.9
222
222
  signing_key:
223
223
  specification_version: 4
224
224
  summary: Attributes on Steroids for Plain Old Ruby Objects