ializer 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ializer/version.rb +1 -1
- data/lib/ser/ializer.rb +8 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 436adbeed83a5f03cb2f5efe5f1ed07f3e7647e7fa15732e7af92923bc6165f5
|
4
|
+
data.tar.gz: c4d2dbc6a03164d51eb577a6a1fe084f35dca996739b75c6d78d7760dfb434cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b563551fb9ebdb39f866c6c1fe58977b9e5c074d1ba4bf0e5a3d040efe191056f4728549e0e36cc34b6f33801aecd83638885c86f04affb07c2c28726ca2f38e
|
7
|
+
data.tar.gz: 82aa9bb2072c937b1f23464418744eb7fff88cb90ea8d97b2ce5f9e99249aa71e59f6050b5da6d014bb9edc5d62c6561b127ac14204502ead6b5cfecd3a1dd89
|
data/lib/ializer/version.rb
CHANGED
data/lib/ser/ializer.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
4
|
+
require 'active_support/core_ext/hash'
|
5
|
+
|
3
6
|
module Ser
|
4
7
|
class Ializer # rubocop:disable Metrics/ClassLength
|
5
8
|
@@method_registry = {} # rubocop:disable Style/ClassVars
|
@@ -111,7 +114,7 @@ module Ser
|
|
111
114
|
def _attributes
|
112
115
|
@attributes ||=
|
113
116
|
if equal? Ser::Ializer
|
114
|
-
|
117
|
+
ActiveSupport::HashWithIndifferentAccess.new
|
115
118
|
else
|
116
119
|
superclass._attributes.dup
|
117
120
|
end
|
@@ -168,14 +171,15 @@ module Ser
|
|
168
171
|
|
169
172
|
return _attributes.values unless field_names
|
170
173
|
|
171
|
-
_attributes.values_at(*field_names)
|
174
|
+
_attributes.values_at(*field_names).compact
|
172
175
|
end
|
173
176
|
|
174
|
-
def fields_names_for_serialization(context)
|
177
|
+
def fields_names_for_serialization(context)
|
175
178
|
return nil unless context
|
176
179
|
|
177
180
|
if context.is_a?(Hash)
|
178
|
-
|
181
|
+
context = context.with_indifferent_access
|
182
|
+
return context[:attributes] || context[:include]
|
179
183
|
end
|
180
184
|
|
181
185
|
return context.attributes if context.respond_to?(:attributes)
|