Class: Activity::ResourceList::OrderFormatter

Inherits:
BaseFormatter
  • Object
show all
Defined in:
app/services/activity/resource_list.rb

Overview

Service object: order formatter.

Instance Attribute Summary

Attributes inherited from BaseFormatter

#record

Instance Method Summary collapse

Methods inherited from BaseFormatter

#created_at, #identifier, #initialize, #state

Constructor Details

This class inherits a constructor from Activity::ResourceList::BaseFormatter

Instance Method Details

#displayString

Option label: reference, state, total, and date.

Returns:

  • (String)


293
294
295
# File 'app/services/activity/resource_list.rb', line 293

def display
  [reference_number, state, total, created_at].compact.join(' - ')
end

#ship_toString

Ship-to summary (name, city, state) for the option label.

Returns:

  • (String)


299
300
301
302
303
304
305
# File 'app/services/activity/resource_list.rb', line 299

def ship_to
  [
    shipping_address&.person_name,
    shipping_address&.city,
    shipping_address&.state_code
  ].compact.join(' ')
end

#totalString

Formatted order total.

Returns:

  • (String)


309
310
311
# File 'app/services/activity/resource_list.rb', line 309

def total
  Money.new((record.total || 0) * 100, record.currency).format
end