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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 100d3814b35d079e9ddd05300ea69aeb01d13ddd
4
- data.tar.gz: 8432a699262798dc61effbe9f5994fe63d9f8829
3
+ metadata.gz: 218f72ebf8cd75157a4416fc034ae07d08519d6c
4
+ data.tar.gz: '0192de8497b8263d3b1e66bad9911225be0484e7'
5
5
  SHA512:
6
- metadata.gz: 0bc27fb205558158804e0e264518342aed2183858abf3515c74cf67c0e5e6bb073fbb27bdd6c44ee19ee4143c5d89f75402a15d3475b6cccf44a56918b092e30
7
- data.tar.gz: d76c8deca5278e237bd88f3b1abfe91c5a9956ba226c9673d976ba4fe5b7cc24a9d4ab8727c057c927ee673dd609160c06ab77f1e03e0a90d7f73936a0c245de
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)
@@ -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] ||= { rmv: [ ], add: [ ], final: nil, recursive: [ ], map: { } }
6
+ ActiveSerialize.configs[name] ||= { **ActiveSerialize.configs[:default].deep_dup, final: nil, recursive: [ ], map: { } }
7
7
  end
8
8
 
9
9
  def to_ha(**args)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveSerialize
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_serialize
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
  - zhandao