class FilePipeline::FileOperations::Results
This class contains the results from a FileOperation
being run on a file. Instances will be returned by the FileOperation#run
method.
Instances contain the file operation opbject that has produced self
, a flag for success, and any logs and data the operation may return.
Attributes
Hash with any data returned from an operation.
Array with log messages from operations.
The object (usually an instance of a subclass of FileOperation
) that created self
true
if the operation has finished and produced a version file, or false
if it encountered an error that caused it to terminate.
Public Class Methods
Returns a new instance.
Arguments¶ ↑
-
operation
- Must respond to:name
and:options
. -
success
-true
orfalse
. -
log_data
- A string, error, array, hash, ornil
.
Examples¶ ↑
error = StandardError.new warning = 'a warning occurred' log = [error, warning] data = { mime_type: 'image/jpeg' } my_op = MyOperation.new Results.new(my_op, false, error) # => <Results @data=nil, @log=[error], ..., @success=false> Results.new(my_op, true, warning) # => <Results @data=nil, @log=[warning], ..., @success=true> Results.new(my_op, true, data) # => <Results @data=data, @log=[], ..., @success=true> Results.new(my_op, true, [warning, data]) # => <Results @data=data, @log=[warning], ..., @success=true> Results.new(my_op, false, log) # => <Results @data=nil, @log=[error, warning], ..., @success=false> Results.new(my_op, false, [log, data]) # => <Results @data=data, @log=[error, warning], ..., @success=false> Results.new(my_op, false, nil) # => <Results @data=nil, @log=nil, ..., @success=false>
# File lib/file_pipeline/file_operations/results.rb, line 63 def initialize(operation, success, log_data) @operation = operation @success = success @log, @data = LogDataParser.new log_data end
# File lib/file_pipeline/file_operations/results.rb, line 94 def self.normalize_log_data(obj) return unless obj Results.return_data(obj) || Results.return_log_message(obj) || Results.return_log(obj) || Results.return_log_and_data(obj) end
Public Instance Methods
Returns true
if the operation was not succesful, false
otherwise.
# File lib/file_pipeline/file_operations/results.rb, line 104 def failure !success end