Class: MongoDelta::Outlet::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_delta/outlet/base.rb

Direct Known Subclasses

Replicator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, db, collection, options = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
14
# File 'lib/mongo_delta/outlet/base.rb', line 7

def initialize(target, db, collection, options={})
  @target     = target
  @db         = db
  @collection = collection
  @options    = options

  @target_collection = target.db(options['target_db'] || db).collection(options['target_collection'] || collection)
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



5
6
7
# File 'lib/mongo_delta/outlet/base.rb', line 5

def collection
  @collection
end

#dbObject (readonly)

Returns the value of attribute db.



5
6
7
# File 'lib/mongo_delta/outlet/base.rb', line 5

def db
  @db
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/mongo_delta/outlet/base.rb', line 5

def options
  @options
end

#targetObject (readonly)

Returns the value of attribute target.



5
6
7
# File 'lib/mongo_delta/outlet/base.rb', line 5

def target
  @target
end

#target_collectionObject (readonly)

Returns the value of attribute target_collection.



5
6
7
# File 'lib/mongo_delta/outlet/base.rb', line 5

def target_collection
  @target_collection
end

Instance Method Details

#handles?(db, collection, method) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/mongo_delta/outlet/base.rb', line 20

def handles?(db, collection, method)
  @db == db and @collection == collection and respond_to?(method)
end

#nsObject



16
17
18
# File 'lib/mongo_delta/outlet/base.rb', line 16

def ns
  "#{db}.#{collection}"
end