active_tools 0.2.0 → 0.2.1

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: bb8964cf95b2ee9cf7e0d9f5854173805354d981
4
- data.tar.gz: 33d5409e4d1b58751109e1b8aa37d29994799a34
3
+ metadata.gz: 507869d978bf4ad3d18dc4df23ae57ac3c8865ce
4
+ data.tar.gz: 3e4f5d63774bdc82d86d0433373457a1903c8231
5
5
  SHA512:
6
- metadata.gz: 3f33f7caee1c3e94277410f8136b5dbb36404bfb17fea9ad73490e6fae463c03560275c433ae0ab91fccab90b73269e33476630b67cddd26da7479ccce7d7056
7
- data.tar.gz: 0ab2209bca78f50d5c217915d326491b1b1ad185f77084b71a05db648936679e88fb1ed53a3db36ca54eb866bc2c00eb0e1988c7d473046ea7f32bc1d310bf75
6
+ metadata.gz: 40b3211fa2fbff948d62ba385fe4ba87f1ee8d248b6e1f348446d973ca60ce11c0dd7d59b52f0df8b660e7d1b02d9e8316f6a1cad8701bdf5ff5cfc3140f7ef3
7
+ data.tar.gz: 936b27f1f6671b9270bb193f0434891cfe487b81d55f76cf58d2c0130b0d4fe525f4cd69c8a2262fce912d891450529e7827b80a9b865dffb9e2add0de4d3fb7
@@ -134,7 +134,12 @@ module ActiveTools
134
134
  def update_target_if_changed!
135
135
  if target && target.changes.any?
136
136
  warn "Adaptive is updating: <#{target.class.name}: #{target.class.primary_key}: #{target.send(target.class.primary_key)}>"
137
- owner.touch if @touch
137
+ if @touch
138
+ begin
139
+ owner.touch
140
+ rescue
141
+ end
142
+ end
138
143
  begin
139
144
  target.save
140
145
  rescue ::ActiveRecord::StaleObjectError
@@ -24,18 +24,18 @@ module ActiveTools
24
24
  def custom_counter_cache_after_update(assoc_name, reflection, assoc_mapping)
25
25
  record_changed =
26
26
  if reflection.polymorphic?
27
- send(:attribute_changed?, reflection.foreign_type)||send(:attribute_changed?, reflection.foreign_key)
27
+ send((Rails.version >= "5.1" ? :saved_change_to_attribute? : :attribute_changed?), reflection.foreign_type)||send((Rails.version >= "5.1" ? :saved_change_to_attribute? : :attribute_changed?), reflection.foreign_key)
28
28
  else
29
- send(:attribute_changed?, reflection.foreign_key)
29
+ send((Rails.version >= "5.1" ? :saved_change_to_attribute? : :attribute_changed?), reflection.foreign_key)
30
30
  end
31
31
 
32
32
  if (@_after_create_custom_counter_called ||= false)
33
33
  @_after_create_custom_counter_called = false
34
34
  elsif !new_record? && record_changed
35
35
  model = reflection.options[:polymorphic] ? attribute(reflection.foreign_type).try(:constantize) : reflection.klass
36
- model_was = reflection.options[:polymorphic] ? attribute_was(reflection.foreign_type).try(:constantize) : reflection.klass
36
+ model_was = reflection.options[:polymorphic] ? send((Rails.version >= "5.1" ? :attribute_before_last_save : :attribute_was), reflection.foreign_type).try(:constantize) : reflection.klass
37
37
  foreign_key = attribute(reflection.foreign_key)
38
- foreign_key_was = attribute_was(reflection.foreign_key)
38
+ foreign_key_was = send((Rails.version >= "5.1" ? :attribute_before_last_save : :attribute_was), reflection.foreign_key)
39
39
 
40
40
  if foreign_key && model.respond_to?(:increment_counter) && to_increment = model.find_by_id(foreign_key)
41
41
  ActiveRecord::CustomCounterCache.digger(self, to_increment, assoc_mapping) do |parent, cache_column, value|
@@ -1,3 +1,3 @@
1
1
  module ActiveTools
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valery Kvon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-03 00:00:00.000000000 Z
11
+ date: 2017-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails