Class: FileTransactions::MoveFileCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- FileTransactions::MoveFileCommand
- Defined in:
- lib/file_transactions/move_file_command.rb
Overview
This command supports moveing (renaming) a file. It will also create parent directories if the given path contains directories that doesn’t exist.
When this command has been executed, the file can be moved back to the original location again by calling #undo. Any directories created during #execute will be deleted.
Examples
cmd1 = MoveFileCommand.new('some_existing_file', 'some_new_dir/a_new_name')
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(from:, to:) ⇒ MoveFileCommand
constructor
A new instance of MoveFileCommand.
Methods inherited from BaseCommand
execute, #execute, #executed?, #failed?, #register, #undo
Constructor Details
#initialize(from:, to:) ⇒ MoveFileCommand
Returns a new instance of MoveFileCommand.
19 20 21 22 |
# File 'lib/file_transactions/move_file_command.rb', line 19 def initialize(from:, to:) @from = from @to = to end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
15 16 17 |
# File 'lib/file_transactions/move_file_command.rb', line 15 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
15 16 17 |
# File 'lib/file_transactions/move_file_command.rb', line 15 def to @to end |