Class: TypedEAV::CSVMapper::Result
- Inherits:
-
Object
- Object
- TypedEAV::CSVMapper::Result
- Defined in:
- lib/typed_eav/csv_mapper.rb
Overview
Plain value object — NOT an ActiveRecord model. No callbacks, no
validations, no DB interaction. Two frozen Hashes; success? is just
errors.empty?. Callers that need to combine multiple row Results
into a batch view do so by composing the immutable Hashes in their
own code (e.g., results.flat_map(&:errors).reduce({}, :merge)); the
mapper does not provide a "merge" helper in v0.6.0.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(attributes:, errors:) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(attributes:, errors:) ⇒ Result
Returns a new instance of Result.
77 78 79 80 |
# File 'lib/typed_eav/csv_mapper.rb', line 77 def initialize(attributes:, errors:) @attributes = attributes.freeze @errors = errors.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
75 76 77 |
# File 'lib/typed_eav/csv_mapper.rb', line 75 def attributes @attributes end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
75 76 77 |
# File 'lib/typed_eav/csv_mapper.rb', line 75 def errors @errors end |
Instance Method Details
#failure? ⇒ Boolean
86 87 88 |
# File 'lib/typed_eav/csv_mapper.rb', line 86 def failure? !success? end |
#success? ⇒ Boolean
82 83 84 |
# File 'lib/typed_eav/csv_mapper.rb', line 82 def success? @errors.empty? end |