Class: Spree::CSV::NewsletterSubscriberPresenter

Inherits:
Object
  • Object
show all
Includes:
MetafieldsHelper
Defined in:
app/presenters/spree/csv/newsletter_subscriber_presenter.rb

Constant Summary collapse

HEADERS =
[
  'Email',
  'Customer Name',
  'Customer ID',
  'Verified',
  'Verified At',
  'Created At',
  'Updated At'
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(newsletter_subscriber) ⇒ NewsletterSubscriberPresenter



16
17
18
# File 'app/presenters/spree/csv/newsletter_subscriber_presenter.rb', line 16

def initialize(newsletter_subscriber)
  @newsletter_subscriber = newsletter_subscriber
end

Instance Attribute Details

#newsletter_subscriberObject

Returns the value of attribute newsletter_subscriber.



20
21
22
# File 'app/presenters/spree/csv/newsletter_subscriber_presenter.rb', line 20

def newsletter_subscriber
  @newsletter_subscriber
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/presenters/spree/csv/newsletter_subscriber_presenter.rb', line 22

def call
  csv = [
    newsletter_subscriber.email,
    newsletter_subscriber.user&.full_name,
    newsletter_subscriber.user_id,
    newsletter_subscriber.verified? ? Spree.t(:say_yes) : Spree.t(:say_no),
    newsletter_subscriber.verified_at,
    newsletter_subscriber.created_at,
    newsletter_subscriber.updated_at
  ]

  csv += metafields_for_csv(newsletter_subscriber)

  csv
end