active_touch 1.4.0 → 1.4.1

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
- ZWFlZTI2MzdlMmFiOTQ1MTI0ZDg0YmFiMWViYjNhZGE5MWQ0YmNiNw==
4
+ ODgwY2MxMTg4NjI5ZjZmZDJkMTI1N2Q0MmVjMDAzZjFlZDNiYzEwMg==
5
5
  data.tar.gz: !binary |-
6
- N2RlYTU2MGNmODZjMTBlZTFmYTIwMGI5MTU0NDg1YzI1OWQyMmFjMQ==
6
+ ODkyYTA3YzMwYmM0NmJhM2JiNjU3NTk1Y2E3ZmQxMDAxYmQ0NTc0NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2JjNTcwMTQ2ZDI3ZWM3ZWUxZjEwZDhlZjJhM2I4YWQ4N2FiYWYzNzM1Njhi
10
- MjVjMWFlODNjYTQ3NzcwZjAxNGUxMmJlMzM1ZjYzNGI4NTdlNWNkMjhhZTFl
11
- MjYzNDNkOTg0YzQwMWIyZjhlNjZmZDE2ZmI1N2QyN2RmNzNmYTU=
9
+ MDIxYTdjNjViZWNjZmFkY2NlMWRjZjQ3MjQ4YzU3NWUxMjgyYTVlYmQxM2Jj
10
+ ZTZkNTc2MWNiNDEzNzI1YjZhMjYzZWYyZTM3OTFmNGI5YmVlMTEyZWY5MWU5
11
+ MDUzNDEwM2ZmOWFiMmIwMGY5MTVjNzY2OTEzYWExZDg3NTc5YzE=
12
12
  data.tar.gz: !binary |-
13
- ZjM5Y2UwYzUxZWIwNmMyMmJiOWJiM2MzYTZiODczMzFhNzlkMjU1NjgyNDI0
14
- Y2JlNmI4YmUxY2YxOTcwMDBjNDMwZGZhMGI0MTdmNzk0Mjg0NmU3ZjFjNjRi
15
- N2YzMzdlZDJmMTg0NTA2MmU1YTNhNzZiZjYzMWNhNWRkYzcyYzU=
13
+ ZWIyOGY0OGNjNDE2ZjlhZWE3ZmI2YzBjYWJlMzlkMWY4YWRjNDM5ODVhYTkx
14
+ NDFjMzkzNDhmNjQ3YjcxMzc2NmQyOWVjYmU4Mjk3MTlkOWFmMzhkODZlOThh
15
+ YWVjZmNhZmI3MDQ1Mjc4YjZiYjk2ZWFjOGFkMzZmZjE0ZWFlYmM=
data/README.md CHANGED
@@ -14,7 +14,7 @@ gem 'activetouch', '~> 1.4.0'
14
14
 
15
15
  Then run the installer:
16
16
 
17
- ```ruby
17
+ ```sh
18
18
  rails g active_touch:install
19
19
  ```
20
20
 
data/lib/active_touch.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'active_touch/version'
2
2
  require 'active_touch/configuration'
3
3
  require 'active_touch/define_touch'
4
+ require 'active_touch/network'
4
5
  require 'active_touch/touch_job'
5
6
 
6
7
  require 'active_support/concern'
@@ -15,6 +15,7 @@ module ActiveTouch
15
15
  def define
16
16
  define_touch_method
17
17
  add_active_record_callback
18
+ add_to_network
18
19
  end
19
20
 
20
21
  def define_touch_method
@@ -47,6 +48,11 @@ module ActiveTouch
47
48
  @klass.send(:after_commit) { send(touch_method) }
48
49
  end
49
50
 
51
+ def add_to_network
52
+ touched = @options[:class_name] || @association.to_s.camelize
53
+ ActiveTouch.network.add_touch(@klass.to_s, touched, @options[:watch])
54
+ end
55
+
50
56
  def default_options
51
57
  {
52
58
  async: ActiveTouch.configuration.async,
@@ -0,0 +1,35 @@
1
+ module ActiveTouch
2
+
3
+ class << self
4
+ attr_accessor :network
5
+ end
6
+
7
+ def self.network
8
+ @network ||= Network.new
9
+ end
10
+
11
+ class Network
12
+
13
+ attr_accessor :map
14
+
15
+ def initialize
16
+ @map = {}
17
+ end
18
+
19
+ # @param caller [String]
20
+ # @param touched [String, Array(String)]
21
+ # @param watch [Array(Symbol)]
22
+ # @return [void]
23
+ def add_touch(caller, touched, watch)
24
+ map[caller] ||= []
25
+
26
+ if touched.is_a? Array
27
+ touched.each { |t| map[caller] << { class: t, attributes: watch } }
28
+ else
29
+ map[caller] << { class: touched, attributes: watch }
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -13,8 +13,10 @@ module ActiveTouch
13
13
  associated.send(after_touch) unless after_touch.blank?
14
14
 
15
15
  elsif !associated.nil?
16
- associated.update_all(updated_at: record.updated_at)
17
- associated.each { |associate| associate.send(after_touch) } unless after_touch.blank?
16
+ associated.each do |associate|
17
+ associate.update_columns(updated_at: record.updated_at)
18
+ associate.send(after_touch) unless after_touch.blank?
19
+ end
18
20
  end
19
21
  end
20
22
 
@@ -1,3 +1,3 @@
1
1
  module ActiveTouch
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  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: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Pheasey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-18 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,7 @@ files:
73
73
  - lib/active_touch.rb
74
74
  - lib/active_touch/configuration.rb
75
75
  - lib/active_touch/define_touch.rb
76
+ - lib/active_touch/network.rb
76
77
  - lib/active_touch/touch_job.rb
77
78
  - lib/active_touch/version.rb
78
79
  - lib/generators/active_touch/initializer_generator.rb