ar_sync 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 377f042b14b49b79d357904e68e4382639dc1c37159ad9215385fe7e0dc3ecfa
4
- data.tar.gz: 808503bd17cf312fdfca041cf7aad54c645c164a77ab1ce83888e5e93c9397ec
3
+ metadata.gz: 949fc166a975785ab522fe3a2714bf334a56c1f2d4e32931aced7b3ee1de65ac
4
+ data.tar.gz: f9428cc4dbf7e2e7cea7c2f958198e628f7ad92241d71c351e8328b856a315de
5
5
  SHA512:
6
- metadata.gz: 9eb9a61473330c89049a89bb5ff8448d51b1c47a41b5d52f68d9a2b9826dc69454ea3fef0dceae5287b1c073600354a0be01eea96fc6f6d6a91cc64e611b4d05
7
- data.tar.gz: 1a9cc66d3184ec1aca56d6812aa950b1496072b6d1bdab3c7bf9b2c3241e6126359e9900adef7b54cce7cf498181430a8eef211083ddbede087dd616caf08fcb
6
+ metadata.gz: dff083ce7735e475c3104b7581da185e8bd872e76afd8addeecfd5ebc9d292cb299358edeb9d445c5aac268813d4bd358a886bd89dff761eab8dbbac2fa75593
7
+ data.tar.gz: 54ce2594a8749284200924456188fc7b7a3836f8719cbaea4b2626823e9bbe1879cc6a8d7dad327e82f83d7f48d488620eef18f94bda6297aecf1c87d3893b85
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ar_sync (1.0.2)
4
+ ar_sync (1.0.3)
5
5
  activerecord
6
6
  ar_serializer (= 1.0.0)
7
7
 
@@ -110,20 +110,28 @@ module ArSync::ModelBase::ClassMethods
110
110
  sync_parent collection, inverse_of: [self, name]
111
111
  end
112
112
 
113
+ module WriteHook
114
+ def _initialize_sync_info_before_mutation
115
+ self.class.default_scoped.scoping do
116
+ @_sync_watch_values_before_mutation ||= _sync_current_watch_values
117
+ @_sync_parents_info_before_mutation ||= _sync_current_parents_info
118
+ @_sync_belongs_to_info_before_mutation ||= _sync_current_belongs_to_info
119
+ end
120
+ end
121
+ def _write_attribute(attr_name, value)
122
+ _initialize_sync_info_before_mutation
123
+ super attr_name, value
124
+ end
125
+ def write_attribute(attr_name, value)
126
+ _initialize_sync_info_before_mutation
127
+ super attr_name, value
128
+ end
129
+ end
130
+
113
131
  def _initialize_sync_callbacks
114
132
  return if instance_variable_defined? '@_sync_callbacks_initialized'
115
133
  @_sync_callbacks_initialized = true
116
- mod = Module.new do
117
- def _write_attribute(attr_name, value)
118
- self.class.default_scoped.scoping do
119
- @_sync_watch_values_before_mutation ||= _sync_current_watch_values
120
- @_sync_parents_info_before_mutation ||= _sync_current_parents_info
121
- @_sync_belongs_to_info_before_mutation ||= _sync_current_belongs_to_info
122
- end
123
- super attr_name, value
124
- end
125
- end
126
- prepend mod
134
+ prepend WriteHook
127
135
  attr_reader :_sync_parents_info_before_mutation, :_sync_belongs_to_info_before_mutation, :_sync_watch_values_before_mutation
128
136
 
129
137
  _sync_define :id
@@ -1,3 +1,3 @@
1
1
  module ArSync
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -2,7 +2,6 @@
2
2
  "name": "ar_sync",
3
3
  "version": "0.0.1",
4
4
  "scripts": {
5
- "prepare": "tsc",
6
5
  "build": "tsc"
7
6
  },
8
7
  "dependencies": {},
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tompng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-27 00:00:00.000000000 Z
11
+ date: 2019-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord