Module: Billfold::ActiveRecordUser::InstanceMethods

Defined in:
lib/billfold/active_record_user.rb

Instance Method Summary collapse

Instance Method Details

#merge_into!(other) ⇒ Object

Merge this user into another user, deleting this user and moving its identities to the other.

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
# File 'lib/billfold/active_record_user.rb', line 24

def merge_into!(other)
  raise ArgumentError.new("#{other} is not a #{Billfold.user_class}") unless other.kind_of?(Billfold.user_class)
  raise ArgumentError.new("#{other} is not saved") if other.new_record?
  transaction do
    identities.update_all({ :user_id => other.id })
    perform_additional_merge_operations!(other)
    destroy
  end
end