Class: TypedEAV::CSVMapper::Result

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



75
76
77
# File 'lib/typed_eav/csv_mapper.rb', line 75

def attributes
  @attributes
end

#errorsObject (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

Returns:

  • (Boolean)


86
87
88
# File 'lib/typed_eav/csv_mapper.rb', line 86

def failure?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/typed_eav/csv_mapper.rb', line 82

def success?
  @errors.empty?
end