Class: DatedBackup::ExecutionContext::Around

Inherits:
Object
  • Object
show all
Defined in:
lib/dated_backup/dsl/execution_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(around = self, &blk) ⇒ Around

Returns a new instance of Around.



51
52
53
# File 'lib/dated_backup/dsl/execution_context.rb', line 51

def initialize(around=self, &blk)
  around.instance_eval &blk
end

Instance Method Details

#__anonymous_time_classObject



55
56
57
58
59
60
61
# File 'lib/dated_backup/dsl/execution_context.rb', line 55

def __anonymous_time_class
  Class.new do
    extend DSL::TimeExtensions::ClassMethods
    include DSL::TimeExtensions
    self.add_all_time_methods
  end
end

#__eval_in_context(sym = :time, &blk) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/dated_backup/dsl/execution_context.rb', line 63

def __eval_in_context(sym=:time, &blk)
  instance = instance_eval("__anonymous_#{sym}_class.new")
  instance.instance_eval do
    instance_eval(&blk)
  end
  instance
end

#remove_old(&blk) ⇒ Object



71
72
73
74
# File 'lib/dated_backup/dsl/execution_context.rb', line 71

def remove_old(&blk)
  instance = __eval_in_context(:time, &blk)
  Core::BackupRemover.remove!(Main.instance.backup_root, instance.kept)
end