Module: Locomotive::Extensions::ContentEntry::Csv

Extended by:
ActiveSupport::Concern
Included in:
ContentEntry
Defined in:
app/models/locomotive/extensions/content_entry/csv.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#to_values(options = {}) ⇒ Array

Get the values from the custom fields as an array. Values are ordered by the position of the custom fields. It also adds the created_at value of the instance.

Parameters:

  • options (Hash) (defaults to: {})

    For now, stores only the host for the File fields.

Returns:

  • (Array)


16
17
18
19
20
21
22
23
# File 'app/models/locomotive/extensions/content_entry/csv.rb', line 16

def to_values(options = {})
  values = self.content_type.ordered_entries_custom_fields.map do |field|
    value = self.send(field.name)
    self.value_from_type(field.type.to_sym, value, options)
  end.compact

  values << I18n.l(self.created_at, format: :long)
end