Class: PoringBackup::Setting
- Inherits:
-
Object
- Object
- PoringBackup::Setting
- Includes:
- PoringBackup::Settings::Callback
- Defined in:
- lib/poring_backup/setting.rb
Instance Attribute Summary collapse
-
#after_actions ⇒ Object
readonly
Returns the value of attribute after_actions.
-
#before_actions ⇒ Object
readonly
Returns the value of attribute before_actions.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#databases ⇒ Object
readonly
Returns the value of attribute databases.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#storages ⇒ Object
readonly
Returns the value of attribute storages.
-
#tmp_dir ⇒ Object
readonly
Returns the value of attribute tmp_dir.
Instance Method Summary collapse
- #clear_tmp! ⇒ Object
- #database(model, &block) ⇒ Object
-
#initialize(&block) ⇒ Setting
constructor
A new instance of Setting.
- #perform! ⇒ Object
- #store_with(model, &block) ⇒ Object
Methods included from PoringBackup::Settings::Callback
Constructor Details
#initialize(&block) ⇒ Setting
Returns a new instance of Setting.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/poring_backup/setting.rb', line 12 def initialize &block @created_at = Time.now.strftime("%Y.%m.%d.%H.%M.%S") @before_actions = [] @after_actions = [] @dir = 'poring_backups' @tmp_dir = "tmp/poring_backups" @databases = [] @storages = [] instance_eval(&block) if block_given? end |
Instance Attribute Details
#after_actions ⇒ Object (readonly)
Returns the value of attribute after_actions.
7 8 9 |
# File 'lib/poring_backup/setting.rb', line 7 def after_actions @after_actions end |
#before_actions ⇒ Object (readonly)
Returns the value of attribute before_actions.
7 8 9 |
# File 'lib/poring_backup/setting.rb', line 7 def before_actions @before_actions end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/poring_backup/setting.rb', line 10 def created_at @created_at end |
#databases ⇒ Object (readonly)
Returns the value of attribute databases.
9 10 11 |
# File 'lib/poring_backup/setting.rb', line 9 def databases @databases end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
8 9 10 |
# File 'lib/poring_backup/setting.rb', line 8 def dir @dir end |
#storages ⇒ Object (readonly)
Returns the value of attribute storages.
9 10 11 |
# File 'lib/poring_backup/setting.rb', line 9 def storages @storages end |
#tmp_dir ⇒ Object (readonly)
Returns the value of attribute tmp_dir.
8 9 10 |
# File 'lib/poring_backup/setting.rb', line 8 def tmp_dir @tmp_dir end |
Instance Method Details
#clear_tmp! ⇒ Object
41 42 43 44 |
# File 'lib/poring_backup/setting.rb', line 41 def clear_tmp! FileUtils.rm_rf(tmp_dir) PoringBackup.logger.debug "clear tmp directory" end |
#database(model, &block) ⇒ Object
23 24 25 |
# File 'lib/poring_backup/setting.rb', line 23 def database model, &block @databases << class_from_scope(Databases, model).new(self, &block) end |
#perform! ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/poring_backup/setting.rb', line 31 def perform! PoringBackup.logger.info "PoringBackup Start..." before_backup backup! store! clear_tmp! after_backup PoringBackup.logger.info "PoringBackup Done" end |
#store_with(model, &block) ⇒ Object
27 28 29 |
# File 'lib/poring_backup/setting.rb', line 27 def store_with model, &block @storages << class_from_scope(Storages, model).new(self, &block) end |