Class: Agave::Dump::Operation::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/agave/dump/operation/directory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, path) ⇒ Directory

Returns a new instance of Directory.



10
11
12
13
14
# File 'lib/agave/dump/operation/directory.rb', line 10

def initialize(context, path)
  @context = context
  @path = File.join(context.path, path)
  @operations = []
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/agave/dump/operation/directory.rb', line 8

def context
  @context
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/agave/dump/operation/directory.rb', line 8

def path
  @path
end

Instance Method Details

#add(operation) ⇒ Object



16
17
18
# File 'lib/agave/dump/operation/directory.rb', line 16

def add(operation)
  @operations << operation
end

#performObject



20
21
22
23
24
25
26
# File 'lib/agave/dump/operation/directory.rb', line 20

def perform
  FileUtils.remove_dir(path) if Dir.exist?(path)

  FileUtils.mkdir_p(path)

  operations.each(&:perform)
end