mongo_watchable 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.
- data/lib/mongo_watchable/watchable.rb +14 -11
- data/lib/mongo_watchable/watcher.rb +18 -13
- metadata +4 -4
@@ -3,24 +3,26 @@ module MongoWatchable
|
|
3
3
|
def self.included(watchable)
|
4
4
|
watchable.class_eval do
|
5
5
|
MongoWatchable.watchers.each do |watcher|
|
6
|
-
|
7
|
-
key :"#{
|
8
|
-
|
6
|
+
watcher_key_prefix = watcher.name.underscore.gsub(/\//, '_')
|
7
|
+
key :"#{watcher_key_prefix}_watcher_ids", Array
|
8
|
+
key :"#{watcher_key_prefix}_watchers_count", Integer, :default => 0
|
9
|
+
ensure_index :"#{watcher_key_prefix}_watchers_count"
|
9
10
|
|
10
|
-
define_method :"#{
|
11
|
-
MongoWatchable::Proxy.new(self, :"#{
|
11
|
+
define_method :"#{watcher_key_prefix}_watchers" do
|
12
|
+
MongoWatchable::Proxy.new(self, :"#{watcher_key_prefix}_watcher_ids", :"#{watcher_key_prefix}_watchers_count", watcher)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
MongoWatchable.watchers.each do |watcher|
|
17
18
|
watcher.class_eval do
|
18
|
-
|
19
|
-
key :"#{
|
20
|
-
|
19
|
+
watchable_key_prefix = watchable.name.underscore.gsub(/\//, '_')
|
20
|
+
key :"#{watchable_key_prefix}_watching_ids", Array
|
21
|
+
key :"#{watchable_key_prefix}_watchings_count", Integer, :default => 0
|
22
|
+
ensure_index :"#{watchable_key_prefix}_watchings_count"
|
21
23
|
|
22
|
-
define_method :"#{
|
23
|
-
MongoWatchable::Proxy.new(self, :"#{
|
24
|
+
define_method :"#{watchable_key_prefix}_watchings" do
|
25
|
+
MongoWatchable::Proxy.new(self, :"#{watchable_key_prefix}_watching_ids", :"#{watchable_key_prefix}_watchings_count", watchable)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -32,7 +34,8 @@ module MongoWatchable
|
|
32
34
|
while klass.superclass && klass.superclass.include?(MongoWatchable::Watcher)
|
33
35
|
klass = klass.superclass
|
34
36
|
end
|
35
|
-
|
37
|
+
watcher_key_prefix = klass.name.underscore.gsub(/\//, '_')
|
38
|
+
send("#{watcher_key_prefix}_watchers")
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -3,24 +3,26 @@ module MongoWatchable
|
|
3
3
|
def self.included(watcher)
|
4
4
|
watcher.class_eval do
|
5
5
|
MongoWatchable.watchables.each do |watchable|
|
6
|
-
|
7
|
-
key :"#{
|
8
|
-
|
6
|
+
watchable_key_prefix = watchable.name.underscore.gsub(/\//, '_')
|
7
|
+
key :"#{watchable_key_prefix}_watching_ids", Array
|
8
|
+
key :"#{watchable_key_prefix}_watchings_count", Integer, :default => 0
|
9
|
+
ensure_index :"#{watchable_key_prefix}_watchings_count"
|
9
10
|
|
10
|
-
define_method :"#{
|
11
|
-
MongoWatchable::Proxy.new(self, :"#{
|
11
|
+
define_method :"#{watchable_key_prefix}_watchings" do
|
12
|
+
MongoWatchable::Proxy.new(self, :"#{watchable_key_prefix}_watching_ids", :"#{watchable_key_prefix}_watchings_count", watchable)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
MongoWatchable.watchables.each do |watchable|
|
17
18
|
watchable.class_eval do
|
18
|
-
|
19
|
-
key :"#{
|
20
|
-
|
19
|
+
watcher_key_prefix = watcher.name.underscore.gsub(/\//, '_')
|
20
|
+
key :"#{watcher_key_prefix}_watcher_ids", Array
|
21
|
+
key :"#{watcher_key_prefix}_watchers_count", Integer, :default => 0
|
22
|
+
ensure_index :"#{watcher_key_prefix}_watchers_count"
|
21
23
|
|
22
|
-
define_method :"#{
|
23
|
-
MongoWatchable::Proxy.new(self, :"#{
|
24
|
+
define_method :"#{watcher_key_prefix}_watchers" do
|
25
|
+
MongoWatchable::Proxy.new(self, :"#{watcher_key_prefix}_watcher_ids", :"#{watcher_key_prefix}_watchers_count", watcher)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -69,7 +71,8 @@ module MongoWatchable
|
|
69
71
|
while klass.superclass && klass.superclass.include?(MongoWatchable::Watchable)
|
70
72
|
klass = klass.superclass
|
71
73
|
end
|
72
|
-
|
74
|
+
watchable_key_prefix = klass.name.underscore.gsub(/\//, '_')
|
75
|
+
send("#{watchable_key_prefix}_watching_ids")
|
73
76
|
end
|
74
77
|
|
75
78
|
def watchings_proxy_for(watchable)
|
@@ -77,7 +80,8 @@ module MongoWatchable
|
|
77
80
|
while klass.superclass && klass.superclass.include?(MongoWatchable::Watchable)
|
78
81
|
klass = klass.superclass
|
79
82
|
end
|
80
|
-
|
83
|
+
watchable_key_prefix = klass.name.underscore.gsub(/\//, '_')
|
84
|
+
send("#{watchable_key_prefix}_watchings")
|
81
85
|
end
|
82
86
|
|
83
87
|
def watchings_count_proxy_for(watchable)
|
@@ -85,7 +89,8 @@ module MongoWatchable
|
|
85
89
|
while klass.superclass && klass.superclass.include?(MongoWatchable::Watchable)
|
86
90
|
klass = klass.superclass
|
87
91
|
end
|
88
|
-
|
92
|
+
watchable_key_prefix = klass.name.underscore.gsub(/\//, '_')
|
93
|
+
send("#{watchable_key_prefix}_watchings")
|
89
94
|
end
|
90
95
|
|
91
96
|
private
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_watchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonathan Bell
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-09 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|