Sha256: d3771383f097762641e5dd780136d26e36b7daaab0e8b39d53592309dc990171

Contents?: true

Size: 646 Bytes

Versions: 5

Compression:

Stored size: 646 Bytes

Contents

module CSVImporter
  # This Dsl extends a class that includes CSVImporter
  # It is a thin proxy to the Config object
  module Dsl
    def model(model_klass)
      config.model = model_klass
    end

    def column(name, options={})
      config.column_definitions << options.merge(name: name)
    end

    def identifier(*identifiers)
      config.identifiers = identifiers
    end

    alias_method :identifiers, :identifier

    def when_invalid(action)
      config.when_invalid = action
    end

    def after_build(&block)
      config.after_build(block)
    end

    def after_save(&block)
      config.after_save(block)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
csv-importer-0.4.0 lib/csv_importer/dsl.rb
csv-importer-0.3.2 lib/csv_importer/dsl.rb
csv-importer-0.3.1 lib/csv_importer/dsl.rb
csv-importer-0.3.0 lib/csv_importer/dsl.rb
csv-importer-0.2.0 lib/csv_importer/dsl.rb