summaryrefslogtreecommitdiff
path: root/lib/tapicero_daemon.rb
blob: 9020fa2e61fbae6ba460b405474cec7a0355eec4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# This file should not be required directly. Use the wrapper in /bin
# instead or run this using daemons:
#
#  Daemons.run('tapicero_daemon.rb')
#

require 'tapicero'

module Tapicero
  users = CouchRest::Changes.new('users')

  users.created do |hash|
    logger.debug "Created user " + hash['id']
    db = user_database(hash['id'])
    db.create
    db.secure(config.options[:security])
  end

  users.deleted do |hash|
    logger.debug "Deleted user " + hash['id']
    db = user_database(hash['id'])
    db.destroy
  end

  users.listen
end