Class: Relationship

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/relationship.rb

Instance Method Summary collapse

Instance Method Details

#swap_parent_and_childObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/models/relationship.rb', line 4

def swap_parent_and_child
  old_parent_type   = self.parent_type
  old_parent_id     = self.parent_id
  old_child_type    = self.child_type
  old_child_id      = self.child_id

  self.parent_type  = old_child_type
  self.parent_id    = old_child_id
  self.child_type   = old_parent_type
  self.child_id     = old_parent_id

  self.save!
end