Class: Dato::Dump::Operation::Directory
- Inherits:
-
Object
- Object
- Dato::Dump::Operation::Directory
- Defined in:
- lib/dato/dump/operation/directory.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add(operation) ⇒ Object
-
#initialize(context, path) ⇒ Directory
constructor
A new instance of Directory.
- #perform ⇒ Object
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
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/dato/dump/operation/directory.rb', line 9 def context @context end |
#path ⇒ Object (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 |
#perform ⇒ Object
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 |