Class: EasyBackup::Specification
- Inherits:
-
Object
- Object
- EasyBackup::Specification
- Defined in:
- lib/easy_backup/specification.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ Specification
constructor
A new instance of Specification.
- #into(resource_class, &block) ⇒ Object
- #run ⇒ Object
- #save(resource_class, &block) ⇒ Object
- #schedule(frequency, *args) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Specification
Returns a new instance of Specification.
4 5 6 7 8 |
# File 'lib/easy_backup/specification.rb', line 4 def initialize(&block) @resources = [] @storages = [] instance_eval &block if block_given? end |
Instance Method Details
#into(resource_class, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/easy_backup/specification.rb', line 16 def into(resource_class, &block) raise "#{resource_class} not respond to save" unless resource_class.instance_methods.include? :save @storages << resource_class.new @storages.last.instance_eval &block if block_given? end |
#run ⇒ Object
29 30 31 32 33 |
# File 'lib/easy_backup/specification.rb', line 29 def run @resources.each do |resource| resource.send_to *@storages end end |
#save(resource_class, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/easy_backup/specification.rb', line 10 def save(resource_class, &block) raise "#{resource_class} not respond to send_to" unless resource_class.instance_methods.include? :send_to @resources << resource_class.new @resources.last.instance_eval &block if block_given? end |
#schedule(frequency, *args) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/easy_backup/specification.rb', line 22 def schedule(frequency, *args) EasyBackup.scheduler.send(frequency, *args) do EasyBackup.configuration.logger.info "[EasyBackup] Starting at #{Time.now}" run end end |