summaryrefslogtreecommitdiff
path: root/lib/tapicero_daemon.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tapicero_daemon.rb')
-rw-r--r--lib/tapicero_daemon.rb26
1 files changed, 5 insertions, 21 deletions
diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb
index 23248e3..89566de 100644
--- a/lib/tapicero_daemon.rb
+++ b/lib/tapicero_daemon.rb
@@ -4,30 +4,14 @@
#
# Daemons.run('tapicero_daemon.rb')
#
-
require 'tapicero'
module Tapicero
- users = CouchRest::Changes.new('users')
-
- users.created do |hash|
- logger.debug "Created user " + hash['id']
- user_database(hash['id']).prepare(config)
- end
+ module Daemon
+ require 'tapicero/user_event_handler'
+ users = CouchRest::Changes.new('users')
+ UserEventHandler.new(users)
+ users.listen
- # Sometimes changes log starts with rev 2. So the
- # detection of is currently not working properly
- # Working around this until a new version of
- # couchrest changes takes this into account.
- users.updated do |hash|
- logger.debug "Updated user " + hash['id']
- user_database(hash['id']).prepare(config)
end
-
- users.deleted do |hash|
- logger.debug "Deleted user " + hash['id']
- user_database(hash['id']).destroy
- end
-
- users.listen
end