active_serialize 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 +4 -4
- data/README.md +4 -0
- data/lib/active_serialize.rb +5 -1
- data/lib/active_serialize/class_methods.rb +1 -1
- data/lib/active_serialize/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 218f72ebf8cd75157a4416fc034ae07d08519d6c
|
4
|
+
data.tar.gz: '0192de8497b8263d3b1e66bad9911225be0484e7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b361297ae5cf9fb1cc8407eece2f4d4ca23ba239bada1d3bd12d76ddd05a155513dafe28a69bd5ed03044d94c93a3225032269332e97a4f992e5d9351859c0dd
|
7
|
+
data.tar.gz: 1f61b48e35c413362589ccdc6a36a2b0fd26ba1fcb59a42ae192ffaee1443d36fd0bf42faf3e2371d9099d1a10e250ad2b55f1aa0f53eede163d00bf9f67eb83
|
data/README.md
CHANGED
@@ -86,6 +86,10 @@ ActiveRecord class method `column_names` (which is called by this gem) shows tha
|
|
86
86
|
|
87
87
|
* Values of addition keys will be the result of calling `public_send`
|
88
88
|
|
89
|
+
### Set default exception and addition keys
|
90
|
+
|
91
|
+
Using `active_serialize_default rmv: [ ], add: [ ]`
|
92
|
+
|
89
93
|
### Add recursive attributes
|
90
94
|
|
91
95
|
* recursive? —— calls `to_h` recursively (/ nested)
|
data/lib/active_serialize.rb
CHANGED
@@ -7,7 +7,7 @@ require 'active_serialize/class_methods'
|
|
7
7
|
|
8
8
|
module ActiveSerialize
|
9
9
|
extend ActiveSupport::Concern
|
10
|
-
cattr_accessor :configs, default: { }
|
10
|
+
cattr_accessor :configs, default: { default: { rmv: [ ], add: [ ] } }
|
11
11
|
|
12
12
|
class_methods do
|
13
13
|
def active_serialize rmv: [ ], add: [ ], recursive: [ ]
|
@@ -19,6 +19,10 @@ module ActiveSerialize
|
|
19
19
|
active_serialize_add *Array(add)
|
20
20
|
active_serialize_add *Array(recursive), recursive: true
|
21
21
|
end
|
22
|
+
|
23
|
+
def active_serialize_default **args
|
24
|
+
ActiveSerialize.configs[:default].merge!(args)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
module ToH
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ActiveSerialize
|
4
4
|
module ClassMethods
|
5
5
|
def _active_serialize
|
6
|
-
ActiveSerialize.configs[name] ||= {
|
6
|
+
ActiveSerialize.configs[name] ||= { **ActiveSerialize.configs[:default].deep_dup, final: nil, recursive: [ ], map: { } }
|
7
7
|
end
|
8
8
|
|
9
9
|
def to_ha(**args)
|