Class: Spree::CSV::GiftCardPresenter
- Inherits:
-
Object
- Object
- Spree::CSV::GiftCardPresenter
- Includes:
- MetafieldsHelper
- Defined in:
- app/presenters/spree/csv/gift_card_presenter.rb
Constant Summary collapse
- HEADERS =
[ 'Code', 'Amount', 'Amount Used', 'Amount Remaining', 'Currency', 'Status', 'Expires At', 'Customer Email', 'Customer First Name', 'Customer Last Name', 'Created At', 'Updated At' ].freeze
Instance Attribute Summary collapse
-
#gift_card ⇒ Object
Returns the value of attribute gift_card.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(gift_card) ⇒ GiftCardPresenter
constructor
A new instance of GiftCardPresenter.
Constructor Details
#initialize(gift_card) ⇒ GiftCardPresenter
Returns a new instance of GiftCardPresenter.
21 22 23 |
# File 'app/presenters/spree/csv/gift_card_presenter.rb', line 21 def initialize(gift_card) @gift_card = gift_card end |
Instance Attribute Details
#gift_card ⇒ Object
Returns the value of attribute gift_card.
25 26 27 |
# File 'app/presenters/spree/csv/gift_card_presenter.rb', line 25 def gift_card @gift_card end |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/presenters/spree/csv/gift_card_presenter.rb', line 27 def call csv = [ gift_card.display_code, gift_card.display_amount, gift_card.display_amount_used, gift_card.display_amount_remaining, gift_card.currency, gift_card.display_state, gift_card.expires_at&.strftime('%Y-%m-%d'), gift_card.user&.email, gift_card.user&.first_name, gift_card.user&.last_name, gift_card.created_at&.strftime('%Y-%m-%d %H:%M:%S'), gift_card.updated_at&.strftime('%Y-%m-%d %H:%M:%S') ] csv += (gift_card) csv end |