Sha256: ea47a5cdab858a49d7a9168cf9493d44cdddc20031ff0d314bb657a9d6c4b79e

Contents?: true

Size: 433 Bytes

Versions: 4

Compression:

Stored size: 433 Bytes

Contents

class Relationship < ActiveRecord::Base
  acts_as_relationship
  
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acts-as-joinable-0.2.6 app/models/relationship.rb
acts-as-joinable-0.2.3 app/models/relationship.rb
acts-as-joinable-0.2.2 app/models/relationship.rb
acts-as-joinable-0.2 app/models/relationship.rb