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 +8 -8
- data/README.md +1 -1
- data/lib/active_touch.rb +1 -0
- data/lib/active_touch/define_touch.rb +6 -0
- data/lib/active_touch/network.rb +35 -0
- data/lib/active_touch/touch_job.rb +4 -2
- data/lib/active_touch/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODgwY2MxMTg4NjI5ZjZmZDJkMTI1N2Q0MmVjMDAzZjFlZDNiYzEwMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODkyYTA3YzMwYmM0NmJhM2JiNjU3NTk1Y2E3ZmQxMDAxYmQ0NTc0NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDIxYTdjNjViZWNjZmFkY2NlMWRjZjQ3MjQ4YzU3NWUxMjgyYTVlYmQxM2Jj
|
10
|
+
ZTZkNTc2MWNiNDEzNzI1YjZhMjYzZWYyZTM3OTFmNGI5YmVlMTEyZWY5MWU5
|
11
|
+
MDUzNDEwM2ZmOWFiMmIwMGY5MTVjNzY2OTEzYWExZDg3NTc5YzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWIyOGY0OGNjNDE2ZjlhZWE3ZmI2YzBjYWJlMzlkMWY4YWRjNDM5ODVhYTkx
|
14
|
+
NDFjMzkzNDhmNjQ3YjcxMzc2NmQyOWVjYmU4Mjk3MTlkOWFmMzhkODZlOThh
|
15
|
+
YWVjZmNhZmI3MDQ1Mjc4YjZiYjk2ZWFjOGFkMzZmZjE0ZWFlYmM=
|
data/README.md
CHANGED
data/lib/active_touch.rb
CHANGED
@@ -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.
|
17
|
-
|
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
|
|
data/lib/active_touch/version.rb
CHANGED
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.
|
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-
|
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
|