Module: OplogEventHandler::ClassMethods
- Defined in:
- lib/oplog_event_handler.rb
Instance Method Summary collapse
- #connect_to(h) ⇒ Object
- #db_name ⇒ Object
- #for_db(db) ⇒ Object
- #host ⇒ Object
- #mapping ⇒ Object
- #on_delete(opts) ⇒ Object
- #on_insert(opts) ⇒ Object
- #on_update(opts) ⇒ Object
- #port ⇒ Object
Instance Method Details
#connect_to(h) ⇒ Object
18 19 20 |
# File 'lib/oplog_event_handler.rb', line 18 def connect_to(h) @connection = h end |
#db_name ⇒ Object
30 31 32 |
# File 'lib/oplog_event_handler.rb', line 30 def db_name @db_name end |
#for_db(db) ⇒ Object
34 35 36 37 |
# File 'lib/oplog_event_handler.rb', line 34 def for_db(db) @db_name = db yield end |
#host ⇒ Object
22 23 24 |
# File 'lib/oplog_event_handler.rb', line 22 def host @connection[:host] end |
#mapping ⇒ Object
39 40 41 |
# File 'lib/oplog_event_handler.rb', line 39 def mapping return @mapping ||= {} end |
#on_delete(opts) ⇒ Object
57 58 59 |
# File 'lib/oplog_event_handler.rb', line 57 def on_delete(opts) mapping[:"delete_#{db_name}_#{opts[:in]}"] = opts[:call] end |
#on_insert(opts) ⇒ Object
43 44 45 |
# File 'lib/oplog_event_handler.rb', line 43 def on_insert(opts) mapping[:"insert_#{db_name}_#{opts[:in]}"] = opts[:call] end |
#on_update(opts) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/oplog_event_handler.rb', line 47 def on_update(opts) if opts[:only].nil? mapping[:"update_#{db_name}_#{opts[:in]}"] = opts[:call] else opts[:only].each do |e| mapping[:"update_#{db_name}_#{opts[:in]}##{e}"] = opts[:call] end end end |
#port ⇒ Object
26 27 28 |
# File 'lib/oplog_event_handler.rb', line 26 def port @connection[:port] end |