Sha256: 59293e98c69cab0e7056203b0af7ac5d38670d6c52e7caf71f55d8bdc6a11ebe

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

class Memberships::Reassignments::ScaffoldingCompletelyConcreteTangibleThingsReassignment < ApplicationRecord
  # 🚅 add concerns above.

  belongs_to :membership # this is the member being reassigned from.
  has_one :team, through: :membership
  # 🚅 add belongs_to associations above.

  has_many :assignments
  has_many :memberships, through: :assignments # these are the members being reassigned to.
  # 🚅 add has_many associations above.

  # 🚅 add has_one associations above.

  # 🚅 add scopes above.

  # 🚅 add validations above.

  after_save :reassign
  # 🚅 add callbacks above.

  # 🚅 add delegations above.

  def valid_memberships
    team.memberships.current_and_invited
  end

  def reassign
    membership.scaffolding_completely_concrete_tangible_things_assignments.each do |existing_assignment|
      memberships.each do |target_membership|
        unless existing_assignment.tangible_thing.memberships.include?(target_membership)
          existing_assignment.tangible_thing.memberships << target_membership
        end
      end
      existing_assignment.destroy
    end
  end
  # 🚅 add methods above.
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bullet_train-1.0.0 app/models/memberships/reassignments/scaffolding_completely_concrete_tangible_things_reassignment.rb