Module: Sequel::DuplicateColumnsHandler

Defined in:
lib/sequel/extensions/duplicate_columns_handler.rb

Instance Method Summary collapse

Instance Method Details

#columns=(cols) ⇒ Object

Override the attr_writer to check for duplicate columns, and call handle_duplicate_columns if necessary.



46
47
48
49
50
51
# File 'lib/sequel/extensions/duplicate_columns_handler.rb', line 46

def columns=(cols)
  if cols && cols.uniq.size != cols.size
    handle_duplicate_columns(cols)
  end
  @columns = cols
end

#on_duplicate_columns(handler = (raise Error, "Must provide either an argument or a block to on_duplicate_columns" unless block_given?; nil), &block) ⇒ Object

Customize handling of duplicate columns for this dataset.

Raises:



39
40
41
42
# File 'lib/sequel/extensions/duplicate_columns_handler.rb', line 39

def on_duplicate_columns(handler = (raise Error, "Must provide either an argument or a block to on_duplicate_columns" unless block_given?; nil), &block)
  raise Error, "Cannot provide both an argument and a block to on_duplicate_columns" if handler && block
  clone(:on_duplicate_columns=>handler||block)
end