Class: Spree::CSV::ProductTranslationPresenter

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

Constant Summary collapse

CSV_HEADERS =
%w[
  slug
  locale
  name
  description
  meta_title
  meta_description
].freeze
TRANSLATABLE_FIELDS =
%i[name description meta_title meta_description].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product, locale) ⇒ ProductTranslationPresenter

Returns a new instance of ProductTranslationPresenter.



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

def initialize(product, locale)
  @product = product
  @locale = locale.to_s
end

Instance Attribute Details

#localeObject (readonly)

Returns the value of attribute locale.



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

def locale
  @locale
end

#productObject (readonly)

Returns the value of attribute product.



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

def product
  @product
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
# File 'app/presenters/spree/csv/product_translation_presenter.rb', line 22

def call
  [
    product.slug,
    locale,
    *TRANSLATABLE_FIELDS.map { |field| product.get_field_with_locale(locale, field) }
  ]
end