Class: Mapper::Postgres::PtoToday

Inherits:
Object
  • Object
show all
Defined in:
lib/bas/mapper/postgres/pto_today.rb

Overview

This class implementats the methods of the Mapper::Base module, specifically designed for preparing or shaping PTO’s data coming from the Fetcher::Postgres::Pto class.

Instance Method Summary collapse

Instance Method Details

#map(pg_response) ⇒ Object

Implements the logic for shaping the results from a fetcher response.


Params:

  • Fetcher::Postgres::Types::Response pg_response: Postgres response object.


returns List<Domain::Pto> ptos_list, mapped PTO’s to be used by a Formatter::Base implementation.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bas/mapper/postgres/pto_today.rb', line 23

def map(pg_response)
  return [] if pg_response.records.empty?

  ptos = build_map(pg_response)

  ptos.map do |pto|
    name = pto["name"]
    start_date = pto["start_date"]
    end_date = pto["end_date"]

    Domain::Pto.new(name, start_date, end_date)
  end
end