Class: Clowne::Adapters::Sequel::Copier

Inherits:
Object
  • Object
show all
Defined in:
lib/clowne/adapters/sequel/copier.rb

Class Method Summary collapse

Class Method Details

.call(source) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/clowne/adapters/sequel/copier.rb', line 8

def call(source)
  nullify_attrs = [:create_timestamp_field, :update_timestamp_field].map do |timestamp|
    source.class.instance_variable_get("@#{timestamp}")
  end + [:id]

  dup_hash = source.dup.to_hash.tap do |hash|
    nullify_attrs.each { |field| hash.delete(field) }
  end

  source.class.new(dup_hash)
end