active_touch 2.0.1 → 3.0.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2RiMTJkNThmYTAwNDliODY3ZGU5MjcwMWZlMmM1ODJiMDUzYTIyNA==
4
+ ODBjYzUzODliMmYyOTVhZjc5Nzc3YjQ4NmUwM2ZjOGIwNDc2OTlhMg==
5
5
  data.tar.gz: !binary |-
6
- ZGE1YzQxN2FlZDAxMDAwNGM2ZGRkZDJhODYyZDg0ZmYzODZkM2Y1ZA==
6
+ MzY4YWUyNTJkYmIwYzU0NGQ1OWFmYzIzMDg0MjNiOWYzOTRjNmM4ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDg2NjI3N2I4MGExYjM1NmY4NWVkNTkyODAzYjczZTQyMWYyMzIyMWZlNjA3
10
- NGZiNTNhZjM2MTVhN2NkMzZhYjdiNTU5ZTdlMTYwYTE0NDE4MTlmNmIwOTc2
11
- OWU4NTVhZWI3NDkxMTU2YjJkYWRhMzVmZTdlY2QxNWJhMWFlMzU=
9
+ ODI1YzViMGI0NTUzODVmMjJhMmM2Nzg0OGUzZGRiYWRhNjk3YWQ1NDBjNGQ4
10
+ NWJkNWI5ZDljYWRjZDY0Y2Q0ZGNkYjFlNWUzZmY4M2Q0MTc3ZjRlNmM3ODg5
11
+ YjBhMzIyNzNiZmRlMmFjZWQzOTFmMDIyOGM1NjYzNzA0MmM0ZDI=
12
12
  data.tar.gz: !binary |-
13
- ZjQ4ZjA5NzJlMTQ0MWM4ODUyOWMxNjhjN2IyYWI2MWFhZGFmMzY0NmNkZmIw
14
- NTZhYmEzYWEyYWFkNzRlYTU3ZDRjZTVlMTgzYTYyN2EwZGY5MDcwNjZhNmY0
15
- ZmE2M2ZiODIzNjllYzI4MmE5NTQzNGY2YjA5NjJhODIyY2Q3MmY=
13
+ NDE1ZDZmNTFlZTIzNzZiMjFkMDM0MGU5ODcxNmM2MTY4MzI3YzhmMDlmY2Nk
14
+ YTc1NTU2NmE3NzhhNTMyODk1ZjAwN2NhOWE4ODAxMDNkYzAzYTFiMTE4YjFk
15
+ Zjc4OTAxMDA4M2E2MTY5MGM1MGQxODFhZGViZmY2NzIzOWM5MzY=
@@ -13,17 +13,13 @@ module ActiveTouch
13
13
  end
14
14
 
15
15
  class Configuration
16
- attr_accessor :associated_touch_delay, :async, :batch_process, :batch_size, :ignored_attributes,
17
- :queue, :touch_process
16
+ attr_accessor :async, :ignored_attributes, :queue, :timestamp_attribute
18
17
 
19
18
  def initialize
20
- @associated_touch_delay = 0
21
19
  @async = false
22
- @batch_process = true
23
- @batch_size = 100
24
20
  @ignored_attributes = [:updated_at]
25
21
  @queue = 'default'
26
- @touch_process = :batch_synchronous
22
+ @timestamp_attribute = :updated_at
27
23
  end
28
24
  end
29
25
 
@@ -5,34 +5,12 @@ module ActiveTouch
5
5
  associated = association == 'self' ? record : record.send(association)
6
6
 
7
7
  if associated.is_a? ActiveRecord::Base
8
- associated.update_columns(updated_at: record.updated_at)
8
+ associated.update_columns(ActiveTouch.timestamp_attribute => record.updated_at) unless ActiveTouch.timestamp_attribute.nil?
9
9
  associated.send(after_touch) unless after_touch.blank?
10
10
 
11
- elsif !associated.nil?
12
-
13
- case ActiveTouch.configuration.touch_process
14
-
15
- when :batch_synchronous
16
- 0.step(associated.count, ActiveTouch.configuration.batch_size).each do |offset|
17
- batch = associated.offset(offset).limit(ActiveTouch.configuration.batch_size)
18
- batch.update_all(updated_at: record.updated_at)
19
- batch.each { |associate| associate.send(after_touch) } unless after_touch.blank?
20
- end
21
-
22
- when :non_batch_asynchronous
23
- associated.each do |associate|
24
- TouchJob
25
- .set(
26
- queue: ActiveTouch.configuration.queue,
27
- wait: ActiveTouch.configuration.associated_touch_delay.seconds
28
- )
29
- .perform_later(associate, 'self', after_touch, is_async)
30
- end
31
-
32
- when :non_batch_synchronous
33
- associated.update_all(updated_at: record.updated_at)
34
- associated.each { |associate| associate.send(after_touch) } unless after_touch.blank?
35
- end
11
+ elsif !associated.nil? && !associated.empty?
12
+ associated.update_all(ActiveTouch.timestamp_attribute => record.updated_at) unless ActiveTouch.timestamp_attribute.nil?
13
+ associated.each { |associate| associate.send(after_touch) } unless after_touch.blank?
36
14
  end
37
15
  end
38
16
 
@@ -1,3 +1,3 @@
1
1
  module ActiveTouch
2
- VERSION = '2.0.1'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -3,14 +3,6 @@ ActiveTouch.configure do |config|
3
3
  # Default is false
4
4
  # config.async = false
5
5
 
6
- # Enable batch processing for large groups of records
7
- # Default is false
8
- # config.batch_processing = false
9
-
10
- # Batch size of records to touch at a time
11
- # Default is 100
12
- # config.batch_size = 100
13
-
14
6
  # When :watch is not specified, ignore the following attributes.
15
7
  # Default is [:updated_at]
16
8
  # config.ignored_attributes = [:updated_at]
@@ -18,4 +10,8 @@ ActiveTouch.configure do |config|
18
10
  # Job queue for asynchronous jobs.
19
11
  # Default is 'default'
20
12
  # config.queue = 'default'
13
+
14
+ # Timestamp attribute to update when touched
15
+ # Default is :updated_at
16
+ # config.timestamp_attribute = 'default'
21
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_touch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Pheasey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-07 00:00:00.000000000 Z
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler