mongo_watchable 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ module MongoWatchable
20
20
  end
21
21
  end
22
22
  end
23
- MongoWatchable.watchables << watchable
23
+ MongoWatchable.register_watchable watchable
24
24
  end
25
25
 
26
26
  def watchers_proxy_for(watcher)
@@ -2,7 +2,7 @@ module MongoWatchable
2
2
  module Watcher
3
3
  def self.included(watcher)
4
4
  watcher.class_eval do
5
- MongoWatchable.watchables do |watchable|
5
+ MongoWatchable.watchables.each do |watchable|
6
6
  key :"#{watchable.name.underscore}_watching_ids", Array
7
7
 
8
8
  define_method :"#{watchable.name.underscore}_watchings" do
@@ -21,7 +21,7 @@ module MongoWatchable
21
21
  end
22
22
  end
23
23
 
24
- MongoWatchable.watchers << watcher
24
+ MongoWatchable.register_watcher watcher
25
25
  end
26
26
 
27
27
  def watch(watchable)
@@ -1,13 +1,30 @@
1
+ require 'active_support/ordered_hash'
1
2
  require 'mongo_watchable/proxy'
2
- require 'mongo_watchable/watcher'
3
- require 'mongo_watchable/watchable'
4
-
5
3
  module MongoWatchable
4
+ def self.register_watchable(watchable)
5
+ @watchables ||= ActiveSupport::OrderedHash.new
6
+ @watchables[watchable.name] = watchable
7
+ end
8
+
6
9
  def self.watchables
7
- @watchables ||= []
10
+ @watchables ||= ActiveSupport::OrderedHash.new
11
+ @watchables.values
12
+ end
13
+
14
+ def self.register_watcher(watcher)
15
+ @watchers ||= ActiveSupport::OrderedHash.new
16
+ @watchers[watcher.name] = watcher
8
17
  end
9
18
 
10
19
  def self.watchers
11
- @watchers ||= []
20
+ @watchers ||= ActiveSupport::OrderedHash.new
21
+ @watchers.values
12
22
  end
13
- end
23
+
24
+ autoload :Watchable, 'mongo_watchable/watchable'
25
+ autoload :Watcher, 'mongo_watchable/watcher'
26
+ end
27
+
28
+ $LOAD_PATH << File.dirname(__FILE__)
29
+ #ActiveSupport::Dependencies.load_paths << File.dirname(__FILE__)
30
+ #ActiveSupport::Dependencies.load_once_paths.delete(File.dirname(__FILE__))
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Bell
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-22 00:00:00 -05:00
17
+ date: 2010-03-25 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency