Sha256: f9d221809e9bb8e210c2cde15f6bcb41337d658a13181ddaa0ec4e46fe5409f1

Contents?: true

Size: 865 Bytes

Versions: 9

Compression:

Stored size: 865 Bytes

Contents

module CSVImporter
  # The configuration of a CSVImporter
  class Config
    include Virtus.model

    attribute :model
    attribute :column_definitions, Array[ColumnDefinition], default: proc { [] }
    attribute :identifiers # Array[Symbol] or Proc
    attribute :when_invalid, Symbol, default: proc { :skip }
    attribute :after_build_blocks, Array[Proc], default: []
    attribute :after_save_blocks, Array[Proc], default: []

    def initialize_copy(orig)
      super
      self.column_definitions = orig.column_definitions.dup
      self.identifiers = orig.identifiers.dup
      self.after_save_blocks = orig.after_save_blocks.dup
      self.after_build_blocks = orig.after_build_blocks.dup
    end

    def after_build(block)
      self.after_build_blocks << block
    end

    def after_save(block)
      self.after_save_blocks << block
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/csv-importer-0.8.2/lib/csv_importer/config.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/csv-importer-0.8.2/lib/csv_importer/config.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/csv-importer-0.8.2/lib/csv_importer/config.rb
csv-importer-0.8.2 lib/csv_importer/config.rb
csv-importer-0.8.1 lib/csv_importer/config.rb
csv-importer-0.8.0 lib/csv_importer/config.rb
csv-importer-0.7.0 lib/csv_importer/config.rb
csv-importer-0.6.0 lib/csv_importer/config.rb
csv-importer-0.5.0 lib/csv_importer/config.rb