Class: LunaPark::Mappers::Simple
- Inherits:
-
Object
- Object
- LunaPark::Mappers::Simple
- Defined in:
- lib/luna_park/mappers/simple.rb
Overview
Abstract mapper for transform data from Entity attributes schema to Database row schema
Direct Known Subclasses
Class Method Summary collapse
- .from_row(_row) ⇒ Object abstract
-
.from_rows(rows) ⇒ Object
Transforms array of rows to array of attribute hashes.
- .to_row(_attrs) ⇒ Object abstract
-
.to_rows(attr_hashes) ⇒ Object
Transforms array of attribute hashes to array of rows.
Class Method Details
.from_row(_row) ⇒ Object
This method is abstract.
85 86 87 |
# File 'lib/luna_park/mappers/simple.rb', line 85 def from_row(_row) raise LunaPark::Errors::AbstractMethod end |
.from_rows(rows) ⇒ Object
Transforms array of rows to array of attribute hashes
68 69 70 71 72 73 |
# File 'lib/luna_park/mappers/simple.rb', line 68 def from_rows(rows) return [] if rows.nil? raise Errors::NotArray.new(input: rows) unless rows.is_a?(Array) rows.to_a.map { |hash| from_row(hash) } end |
.to_row(_attrs) ⇒ Object
This method is abstract.
90 91 92 |
# File 'lib/luna_park/mappers/simple.rb', line 90 def to_row(_attrs) raise LunaPark::Errors::AbstractMethod end |
.to_rows(attr_hashes) ⇒ Object
Transforms array of attribute hashes to array of rows
77 78 79 80 81 82 |
# File 'lib/luna_park/mappers/simple.rb', line 77 def to_rows(attr_hashes) return [] if attr_hashes.nil? raise Errors::NotArray.new(input: attr_hashes) unless attr_hashes.is_a?(Array) attr_hashes.to_a.map { |entity| to_row(entity) } end |