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.
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#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.
-
#notifiers ⇒ Object
readonly
Returns the value of attribute notifiers.
-
#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(name = nil, &block) ⇒ Setting
constructor
A new instance of Setting.
- #notifier(model, &block) ⇒ Object
- #perform! ⇒ Object
- #store_with(model, &block) ⇒ Object
Methods included from PoringBackup::Settings::Callback
Constructor Details
#initialize(name = nil, &block) ⇒ Setting
Returns a new instance of Setting.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/poring_backup/setting.rb', line 13 def initialize name=nil, &block @app_name = name @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 = [] @notifiers = [] instance_eval(&block) if block_given? end |
Instance Attribute Details
#after_actions ⇒ Object (readonly)
Returns the value of attribute after_actions.
8 9 10 |
# File 'lib/poring_backup/setting.rb', line 8 def after_actions @after_actions end |
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
7 8 9 |
# File 'lib/poring_backup/setting.rb', line 7 def app_name @app_name end |
#before_actions ⇒ Object (readonly)
Returns the value of attribute before_actions.
8 9 10 |
# File 'lib/poring_backup/setting.rb', line 8 def before_actions @before_actions end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
11 12 13 |
# File 'lib/poring_backup/setting.rb', line 11 def created_at @created_at end |
#databases ⇒ Object (readonly)
Returns the value of attribute databases.
10 11 12 |
# File 'lib/poring_backup/setting.rb', line 10 def databases @databases end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
9 10 11 |
# File 'lib/poring_backup/setting.rb', line 9 def dir @dir end |
#notifiers ⇒ Object (readonly)
Returns the value of attribute notifiers.
10 11 12 |
# File 'lib/poring_backup/setting.rb', line 10 def notifiers @notifiers end |
#storages ⇒ Object (readonly)
Returns the value of attribute storages.
10 11 12 |
# File 'lib/poring_backup/setting.rb', line 10 def storages @storages end |
#tmp_dir ⇒ Object (readonly)
Returns the value of attribute tmp_dir.
9 10 11 |
# File 'lib/poring_backup/setting.rb', line 9 def tmp_dir @tmp_dir end |
Instance Method Details
#clear_tmp! ⇒ Object
49 50 51 52 |
# File 'lib/poring_backup/setting.rb', line 49 def clear_tmp! FileUtils.rm_rf(tmp_dir) PoringBackup.logger.debug "clear tmp directory" end |
#database(model, &block) ⇒ Object
26 27 28 |
# File 'lib/poring_backup/setting.rb', line 26 def database model, &block @databases << class_from_scope(Databases, model).new(self, &block) end |
#notifier(model, &block) ⇒ Object
34 35 36 |
# File 'lib/poring_backup/setting.rb', line 34 def notifier model, &block @notifiers << class_from_scope(Notifiers, model).new(self, &block) end |
#perform! ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/poring_backup/setting.rb', line 38 def perform! PoringBackup.logger.info "PoringBackup Start..." before_backup backup! store! clear_tmp! after_backup notify! PoringBackup.logger.info "PoringBackup Done" end |
#store_with(model, &block) ⇒ Object
30 31 32 |
# File 'lib/poring_backup/setting.rb', line 30 def store_with model, &block @storages << class_from_scope(Storages, model).new(self, &block) end |