Sha256: 40c7628b90c0df92d22744652c9cd55e8bf5fa9b9e7477d527959a057b1538e1

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

class Cranium::DSL::ImportDefinition

  class << self
    include Cranium::AttributeDSL
  end


  attr_reader :name
  attr_reader :field_associations
  attr_reader :merge_fields

  define_attribute :into
  define_attribute :error_threshold
  define_boolean_attribute :truncate_insert
  define_array_attribute :delete_insert_on
  define_array_attribute :delete_on


  def initialize(name)
    @name = name
    @field_associations = {}
    @merge_fields = {}
  end



  def put(fields)
    @field_associations.merge! fields_hash(fields)
  end



  def merge_on(merge_fields)
    @merge_fields = fields_hash(merge_fields)
  end



  private

  def fields_hash(fields)
    case fields
      when Hash
        return fields
      when Symbol
        return { fields => fields }
      else
        raise ArgumentError, "Unsupported argument for Import::#{caller[0][/`.*'/][1..-2]}"
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cranium-0.8.1 lib/cranium/dsl/import_definition.rb
cranium-0.8 lib/cranium/dsl/import_definition.rb