module Shiftable::ModSignature::SgMethods

Public Instance Methods

has_rel() click to toggle source
# File lib/shiftable/mod_signature.rb, line 121
def has_rel
  associations[:has_one]
end
precheck() click to toggle source

Do not move record if a record already exists (we are shifting a “has_one” association, after all)

# File lib/shiftable/mod_signature.rb, line 126
def precheck
  options[:precheck]
end
shift_data!(shift_to:, shift_from:, bang: false) click to toggle source
# File lib/shiftable/mod_signature.rb, line 130
def shift_data!(shift_to:, shift_from:, bang: false)
  validate_relationships
  shifting = ShiftingRecord.new(
    to: shift_to,
    from: shift_from,
    column: shift_column,
    base: base,
    wrapper: wrapper,
    bang: bang
  ) do
    !precheck || !shift_to.send(has_rel)
  end
  shifting.shift do
    before_shift&.call(shifting)
  end
end