Sha256: f819ee0a78d6b0482a5771dc489a0c6c49c9ba51d045922c258fc41d7f6564b4

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

require 'csv_row_model/concerns/dynamic_columns_base'
require 'csv_row_model/concerns/export/attributes'
require 'csv_row_model/internal/export/dynamic_column_attribute'

module CsvRowModel
  module Export
    module DynamicColumns
      extend ActiveSupport::Concern
      include DynamicColumnsBase

      included do
        ensure_define_dynamic_attribute_method
      end

      def dynamic_column_attribute_objects
        @dynamic_column_attribute_objects ||= array_to_block_hash(self.class.dynamic_column_names) do |column_name|
          self.class.dynamic_attribute_class.new(column_name, self)
        end
      end

      # @return [Array] an array of public_send(column_name) of the CSV model
      def to_row
        super.flatten
      end

      class_methods do
        def dynamic_attribute_class
          DynamicColumnAttribute
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csv_row_model-1.0.0.beta2 lib/csv_row_model/concerns/export/dynamic_columns.rb