Module: MongoComponent
- Defined in:
- lib/goat/mongo.rb
Class Method Summary collapse
- .db_notification_recv(notif) ⇒ Object
- .db_notification_subscribe(coll, depkey, &blk) ⇒ Object
- .db_notifications ⇒ Object
Class Method Details
.db_notification_recv(notif) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/goat/mongo.rb', line 42 def self.db_notification_recv(notif) if notif['obj'] && notif['collection'] depkey = db_notifications[notif['collection']] if depkey && (dep = notif['obj'][depkey]) rerender_and_update([dep]) end else raise "Invalid notification: #{notif.inspect}" end end |
.db_notification_subscribe(coll, depkey, &blk) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/goat/mongo.rb', line 33 def self.db_notification_subscribe(coll, depkey, &blk) db_notifications[coll] = depkey Goat::NotificationCenter.subscribe(self, :db_notification_recv, 'type' => 'db_action', 'collection' => coll ) end |
.db_notifications ⇒ Object
31 |
# File 'lib/goat/mongo.rb', line 31 def self.db_notifications; @db_notifications ||= {}; end |