Class: MongodbClone::MongodbReplication
- Inherits:
-
Object
- Object
- MongodbClone::MongodbReplication
- Defined in:
- lib/mongodb_clone/mongodb_replication.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #dump(environment = 'production', session = 'default') ⇒ Object
-
#initialize ⇒ MongodbReplication
constructor
A new instance of MongodbReplication.
- #restore(environment = 'development', session = 'default') ⇒ Object
Constructor Details
#initialize ⇒ MongodbReplication
Returns a new instance of MongodbReplication.
7 8 9 |
# File 'lib/mongodb_clone/mongodb_replication.rb', line 7 def initialize @id = Time.now.utc.strftime('%Y%m%d%H%M%S') end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/mongodb_clone/mongodb_replication.rb', line 5 def id @id end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/mongodb_clone/mongodb_replication.rb', line 5 def path @path end |
Instance Method Details
#dump(environment = 'production', session = 'default') ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mongodb_clone/mongodb_replication.rb', line 11 def dump(environment = 'production', session = 'default') config = get_config(environment, session) params = default_params(config).merge({ o: "/tmp/#{ config['database'] }/#{ @id }" }) a = hash_to_inline_params(params) command = "mongodump #{ a }" execute(command) @path = "#{ params[:o] }/#{ params[:d] }" self end |
#restore(environment = 'development', session = 'default') ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/mongodb_clone/mongodb_replication.rb', line 27 def restore(environment = 'development', session = 'default') config = get_config(environment, session) a = hash_to_inline_params(default_params(config)) command = "mongorestore --drop #{ a } #{ @path }" execute(command) end |