active_tools 0.2.3 → 0.2.4

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: 687d6ea1e83337571e6a3cff5233ea0b41bb56934817e41018dddf0d2780ab23
4
- data.tar.gz: 4e0751629b4adabae5fc1c220696ce2ee3c5426accd6b402e71e8ad88ba97362
3
+ metadata.gz: 32a0d6d2230e3c9550d6d2f945ee7a979bad0eda3000ec046145073a588d9dcc
4
+ data.tar.gz: 414a438c1f649b9ef4e870fafd91a094fc43472e759142ab4f3a4f3855bfa0a7
5
5
  SHA512:
6
- metadata.gz: df1b30dff6d5c2ea56da8bd85708452c158bc1d0c403a0be6517c82542f8b0e2531bb6894c0b4b05467e9e728cc824dc0a138327739a4b2c522684b43c25d919
7
- data.tar.gz: 551d5973e60c9b616015327243daa85aece3697dd5db6b59c21d2293dc29e53455840d9e84dd64e7999ddfae28bd81b2b6f045cde6541daf6d7fac5ad827ba81
6
+ metadata.gz: b7350ce462a08f8c32fe9c1769624e98c778c253990baea5a04df0cdb1d3d3b0dca42328e87f08393a608ea58b173a2139e5676820b098f28b3e8737979484cd
7
+ data.tar.gz: 6e3d48cfae2b0dc45ff83ecf245ef1c64a2500553eba285e9c43456069aee75347ede1a7f3cf9e0ca889deb34e1fdd4316b5c2dd594bbb48ff76b9395277b0f0
@@ -0,0 +1,33 @@
1
+ module ActiveTools
2
+ module ActiveRecord
3
+ module CommitAndTouch
4
+ extend ::ActiveSupport::Concern
5
+
6
+ included do
7
+ end
8
+
9
+ module ClassMethods
10
+ def commit_and_touch(*args)
11
+ options = args.extract_options!
12
+
13
+ class_attribute :commit_and_touch_options unless defined?(commit_and_touch_options)
14
+ self.commit_and_touch_options ||= {}
15
+ self.commit_and_touch_options[:options] = options
16
+ self.commit_and_touch_options[:reflections] = self.reflections.keys & args.map(&:to_s)
17
+
18
+ after_commit options do
19
+ self.commit_and_touch_options[:reflections].each do |assoc|
20
+ send(assoc).update_all(:updated_at => Time.now)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+
29
+ module OnLoadActiveRecord
30
+ include ActiveRecord::CommitAndTouch
31
+ end
32
+
33
+ end
@@ -4,6 +4,7 @@ require 'active_tools/active_record/custom_counter_cache'
4
4
  require 'active_tools/active_record/with_permalink'
5
5
  require 'active_tools/active_record/polymorphic_conditions'
6
6
  require 'active_tools/active_record/filter_assign'
7
+ require 'active_tools/active_record/commit_and_touch'
7
8
 
8
9
  module ActiveTools
9
10
  module ActiveRecord
@@ -1,3 +1,3 @@
1
1
  module ActiveTools
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valery Kvon
@@ -73,6 +73,7 @@ files:
73
73
  - lib/active_tools/active_model/valid_with/fake_errors.rb
74
74
  - lib/active_tools/active_record/adaptive_belongs_to.rb
75
75
  - lib/active_tools/active_record/adaptive_belongs_to/adapter.rb
76
+ - lib/active_tools/active_record/commit_and_touch.rb
76
77
  - lib/active_tools/active_record/custom_counter_cache.rb
77
78
  - lib/active_tools/active_record/custom_counter_cache/instance_methods.rb
78
79
  - lib/active_tools/active_record/filter_assign.rb