summaryrefslogtreecommitdiff
path: root/lib/tapicero
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2013-11-18 17:18:34 +0100
committerAzul <azul@riseup.net>2013-11-18 17:21:00 +0100
commit38e21726bb9e8f6e0391e50d82e79821fd6c459f (patch)
tree5c987bdb3fcf6dfc65b320dc400dd4e0b850e4ec /lib/tapicero
parent7b2b5472ffc306fff2cdd49cf8415a035093eb5d (diff)
add a hook for reacting on user deletion.
Diffstat (limited to 'lib/tapicero')
-rw-r--r--lib/tapicero/couch_changes.rb10
1 files changed, 9 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"])