mongo_watchable 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- key :"#{watcher.name.underscore}_watcher_ids", Array
7
- key :"#{watcher.name.underscore}_watchers_count", Integer, :default => 0
8
- ensure_index :"#{watcher.name.underscore}_watchers_count"
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 :"#{watcher.name.underscore}_watchers" do
11
- MongoWatchable::Proxy.new(self, :"#{watcher.name.underscore}_watcher_ids", :"#{watcher.name.underscore}_watchers_count", watcher)
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
- key :"#{watchable.name.underscore}_watching_ids", Array
19
- key :"#{watchable.name.underscore}_watchings_count", Integer, :default => 0
20
- ensure_index :"#{watchable.name.underscore}_watchings_count"
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 :"#{watchable.name.underscore}_watchings" do
23
- MongoWatchable::Proxy.new(self, :"#{watchable.name.underscore}_watching_ids", :"#{watchable.name.underscore}_watchings_count", watchable)
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
- send("#{klass.name.underscore}_watchers")
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
- key :"#{watchable.name.underscore}_watching_ids", Array
7
- key :"#{watchable.name.underscore}_watchings_count", Integer, :default => 0
8
- ensure_index :"#{watchable.name.underscore}_watchings_count"
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 :"#{watchable.name.underscore}_watchings" do
11
- MongoWatchable::Proxy.new(self, :"#{watchable.name.underscore}_watching_ids", :"#{watchable.name.underscore}_watchings_count", watchable)
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
- key :"#{watcher.name.underscore}_watcher_ids", Array
19
- key :"#{watcher.name.underscore}_watchers_count", Integer, :default => 0
20
- ensure_index :"#{watcher.name.underscore}_watchers_count"
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 :"#{watcher.name.underscore}_watchers" do
23
- MongoWatchable::Proxy.new(self, :"#{watcher.name.underscore}_watcher_ids", :"#{watcher.name.underscore}_watchers_count", watcher)
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
- send("#{klass.name.underscore}_watching_ids")
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
- send("#{klass.name.underscore}_watchings")
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
- send("#{klass.name.underscore}_watchings")
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: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
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: 2012-11-29 00:00:00 -06:00
18
+ date: 2013-01-09 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency