Class: Mutant::Output
- Inherits:
-
Object
- Object
- Mutant::Output
- Defined in:
- lib/ruby-mutant/output.rb
Instance Attribute Summary collapse
-
#errors ⇒ Array
The get/set for the mutations errors that have been thrown.
-
#meta ⇒ Hash
The hash of metadata the user wants returned from the mutation execution.
-
#success ⇒ Object
readonly
Allows to reading the status of the executed mutation.
Instance Method Summary collapse
-
#add_meta(key, value) ⇒ Object
Adds meta data to the @meta hash (will overwrite existing value).
-
#initialize(success = true, errors = [], meta = {}) ⇒ Output
constructor
Output constructor.
-
#success? ⇒ Boolean
Helper method to determine successfulnes of the mutation that has ran.
Constructor Details
#initialize(success = true, errors = [], meta = {}) ⇒ Output
Output constructor
Parameters:
- success
-
The successful state of the mutation that owns this object. (defaults to ‘true`)
- errors
-
An array of errors that can be packaged and wrapped in this object to be ‘returned` from the mutation’s ‘execute` method. (defaults to `[]`)
- meta
-
A hash map that can be used to set any information that needs to be returned from the mutation to the calling code. (defaults to ‘{}`)
25 26 27 28 29 |
# File 'lib/ruby-mutant/output.rb', line 25 def initialize(success=true, errors=[], ={}) @success = success @errors = errors = end |
Instance Attribute Details
#errors ⇒ Array
Returns The get/set for the mutations errors that have been thrown.
11 12 13 |
# File 'lib/ruby-mutant/output.rb', line 11 def errors @errors end |
#meta ⇒ Hash
Returns the hash of metadata the user wants returned from the mutation execution.
8 9 10 |
# File 'lib/ruby-mutant/output.rb', line 8 def end |
#success ⇒ Object (readonly)
Allows to reading the status of the executed mutation
5 6 7 |
# File 'lib/ruby-mutant/output.rb', line 5 def success @success end |
Instance Method Details
#add_meta(key, value) ⇒ Object
Adds meta data to the @meta hash (will overwrite existing value)
Parameters:
- key
-
A symbol that will be used to store the value in the hash
- value
-
Any value that you wish to store indexed by the ‘key` param. This can be used if you need to return data from the mutation’s ‘execute` method
Returns:
Nothing useful
44 45 46 |
# File 'lib/ruby-mutant/output.rb', line 44 def (key, value) [key] = value end |
#success? ⇒ Boolean
Helper method to determine successfulnes of the mutation that has ran. A successful mutation execution is defined by having an error count of 0. TODO: This needs to be handled better, more smart about what success means
Parameters:
Returns:
A boolean that represents the status of the just execute mutation
56 57 58 |
# File 'lib/ruby-mutant/output.rb', line 56 def success? @success end |