Class: Siba::Source::MongoDb::Init
- Inherits:
-
Object
- Object
- Siba::Source::MongoDb::Init
- Includes:
- LoggerPlug
- Defined in:
- lib/siba-source-mongo-db/init.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
Instance Method Summary collapse
-
#backup(dest_dir) ⇒ Object
Collect source files and put them into dest_dir No return value is expected.
-
#initialize(options) ⇒ Init
constructor
A new instance of Init.
-
#restore(from_dir) ⇒ Object
Restore source files from_dir No return value is expected.
Constructor Details
#initialize(options) ⇒ Init
Returns a new instance of Init.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/siba-source-mongo-db/init.rb', line 11 def initialize() host = Siba::SibaCheck. , "host", true username = Siba::SibaCheck. , "username", true password = Siba::SibaCheck. , "password", true database = Siba::SibaCheck. , "database", true collection = Siba::SibaCheck. , "collection", true @db = Siba::Source::MongoDb::Db.new({ host: host, username: username, password: password, database: database, collection: collection}) end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
9 10 11 |
# File 'lib/siba-source-mongo-db/init.rb', line 9 def db @db end |
Instance Method Details
#backup(dest_dir) ⇒ Object
Collect source files and put them into dest_dir No return value is expected
27 28 29 30 |
# File 'lib/siba-source-mongo-db/init.rb', line 27 def backup(dest_dir) logger.info "Dumping MongoDb#{db.db_and_collection_names}" @db.backup dest_dir end |
#restore(from_dir) ⇒ Object
Restore source files from_dir No return value is expected
34 35 36 37 |
# File 'lib/siba-source-mongo-db/init.rb', line 34 def restore(from_dir) logger.info "Restoring MongoDb#{db.db_and_collection_names}" @db.restore from_dir end |