Class: Spree::CSV::CouponCodePresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spree/csv/coupon_code_presenter.rb

Constant Summary collapse

HEADERS =
[
  'Code',
  'State',
  'Promotion Name',
  'Order Number',
  'Created At',
  'Updated At'
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coupon_code) ⇒ CouponCodePresenter

Returns a new instance of CouponCodePresenter.



13
14
15
# File 'app/presenters/spree/csv/coupon_code_presenter.rb', line 13

def initialize(coupon_code)
  @coupon_code = coupon_code
end

Instance Attribute Details

#coupon_codeObject

Returns the value of attribute coupon_code.



17
18
19
# File 'app/presenters/spree/csv/coupon_code_presenter.rb', line 17

def coupon_code
  @coupon_code
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
28
# File 'app/presenters/spree/csv/coupon_code_presenter.rb', line 19

def call
  [
    coupon_code.display_code,
    coupon_code.state,
    coupon_code.promotion&.name,
    coupon_code.order&.number,
    coupon_code.created_at&.strftime('%Y-%m-%d %H:%M:%S'),
    coupon_code.updated_at&.strftime('%Y-%m-%d %H:%M:%S')
  ]
end