Class: Deliveries::Delivery

Inherits:
Object
  • Object
show all
Defined in:
lib/deliveries/delivery.rb

Direct Known Subclasses

Pickup, Shipment

Constant Summary collapse

ATTRIBUTES =
%i[courier_id sender receiver parcels reference_code tracking_code label].freeze

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Delivery

Returns a new instance of Delivery.



6
7
8
9
10
11
12
13
14
# File 'lib/deliveries/delivery.rb', line 6

def initialize(**attributes)
  self.courier_id = attributes[:courier_id]
  self.sender = attributes[:sender]
  self.receiver = attributes[:receiver]
  self.parcels = attributes[:parcels]
  self.reference_code = attributes[:reference_code]
  self.tracking_code = attributes[:tracking_code]
  self.label = attributes[:label]
end

Instance Method Details

#attributesObject



16
17
18
# File 'lib/deliveries/delivery.rb', line 16

def attributes
  ATTRIBUTES.map { |attr| { attr => send(attr) } }.inject(&:merge)
end