summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tapicero/couch_changes.rb10
-rw-r--r--lib/tapicero_daemon.rb4
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/tapicero/couch_changes.rb b/lib/tapicero/couch_changes.rb
index 376eb11..35d4b1a 100644
--- a/lib/tapicero/couch_changes.rb
+++ b/lib/tapicero/couch_changes.rb
@@ -20,6 +20,14 @@ module Tapicero
end
end
+ def deleted(hash = {}, &block)
+ if block_given?
+ @deleted = block
+ else
+ @deleted && @deleted.call(hash)
+ end
+ end
+
def listen
Tapicero.logger.info "listening..."
Tapicero.logger.debug "Starting at sequence #{since}"
@@ -36,7 +44,7 @@ module Tapicero
def callbacks(hash)
#changed callback
- return if hash["deleted"] # deleted_callback
+ return deleted(hash) if hash["deleted"]
return unless changes = hash["changes"]
created(hash) if changes[0]["rev"].start_with?('1-')
store_seq(hash["seq"])
diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb
index e38a4ad..bb1a818 100644
--- a/lib/tapicero_daemon.rb
+++ b/lib/tapicero_daemon.rb
@@ -21,5 +21,9 @@ module Tapicero
db.secure(Config.security)
end
+ users.deleted do |hash|
+ Tapicero.logger.debug "Deleted user " + hash.to_json
+ end
+
users.listen
end