Module: OplogEventHandler::ClassMethods

Defined in:
lib/oplog_event_handler.rb

Instance Method Summary collapse

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_nameObject



30
31
32
# File 'lib/oplog_event_handler.rb', line 30

def db_name
  @db_name
end

#for_db(db) ⇒ Object



42
43
44
45
# File 'lib/oplog_event_handler.rb', line 42

def for_db(db)
  @db_name = db
  yield
end

#hostObject



22
23
24
# File 'lib/oplog_event_handler.rb', line 22

def host
  @connection[:host]
end

#mappingObject



47
48
49
# File 'lib/oplog_event_handler.rb', line 47

def mapping
  return @mapping ||= {}
end

#on_delete(opts) ⇒ Object



65
66
67
# File 'lib/oplog_event_handler.rb', line 65

def on_delete(opts)
  mapping[:"delete_#{db_name}_#{opts[:in]}"] = opts[:call]
end

#on_insert(opts) ⇒ Object



51
52
53
# File 'lib/oplog_event_handler.rb', line 51

def on_insert(opts)
  mapping[:"insert_#{db_name}_#{opts[:in]}"] = opts[:call]
end

#on_update(opts) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/oplog_event_handler.rb', line 55

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

#oplog_nameObject



38
39
40
# File 'lib/oplog_event_handler.rb', line 38

def oplog_name
  @oplog_name || 'oplog.rs'
end

#portObject



26
27
28
# File 'lib/oplog_event_handler.rb', line 26

def port
  @connection[:port]
end

#set_oplog_name(name) ⇒ Object



34
35
36
# File 'lib/oplog_event_handler.rb', line 34

def set_oplog_name(name)
  @oplog_name = name
end