Class: Dumpcar::Instance
- Inherits:
-
Object
- Object
- Dumpcar::Instance
- Includes:
- ActiveModel::Model
- Defined in:
- lib/dumpcar/instance.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#location ⇒ Object
Returns the value of attribute location.
-
#pg ⇒ Object
Returns the value of attribute pg.
Instance Method Summary collapse
- #cleanup_arguments(arguments) ⇒ Object
- #dump ⇒ Object
-
#initialize(attributes = {}) ⇒ Instance
constructor
A new instance of Instance.
- #restore ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Instance
Returns a new instance of Instance.
7 8 9 10 11 12 |
# File 'lib/dumpcar/instance.rb', line 7 def initialize(attributes = {}) cleanup_arguments(attributes) @connection = Dumpcar::Util.get_connection_db_config @location = Location.new(base_dir) @pg = Pg.new(connection) end |
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
6 7 8 |
# File 'lib/dumpcar/instance.rb', line 6 def base_dir @base_dir end |
#connection ⇒ Object
Returns the value of attribute connection.
6 7 8 |
# File 'lib/dumpcar/instance.rb', line 6 def connection @connection end |
#location ⇒ Object
Returns the value of attribute location.
6 7 8 |
# File 'lib/dumpcar/instance.rb', line 6 def location @location end |
#pg ⇒ Object
Returns the value of attribute pg.
6 7 8 |
# File 'lib/dumpcar/instance.rb', line 6 def pg @pg end |
Instance Method Details
#cleanup_arguments(arguments) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/dumpcar/instance.rb', line 22 def cleanup_arguments(arguments) arguments = arguments.to_h.with_indifferent_access unless arguments.has_key?("base_dir") arguments["base_dir"] = Rails.root.join("db/dumps") end assign_attributes(arguments) end |
#dump ⇒ Object
14 15 16 |
# File 'lib/dumpcar/instance.rb', line 14 def dump @pg.dump(@location.next) end |
#restore ⇒ Object
18 19 20 |
# File 'lib/dumpcar/instance.rb', line 18 def restore @pg.restore(@location.last) end |