Class: Dato::Dump::Operation::Directory

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, path) ⇒ Directory

Returns a new instance of Directory.



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

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.



9
10
11
# File 'lib/dato/dump/operation/directory.rb', line 9

def context
  @context
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/dato/dump/operation/directory.rb', line 9

def path
  @path
end

Instance Method Details

#add(operation) ⇒ Object



17
18
19
# File 'lib/dato/dump/operation/directory.rb', line 17

def add(operation)
  @operations << operation
end

#performObject



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

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

  FileUtils.mkdir_p(path)

  operations.each(&:perform)
end