class Shiftable::ShiftingRelation

Gets data to be shifted

Public Instance Methods

each(&block) click to toggle source
# File lib/shiftable/shifting_relation.rb, line 12
def each(&block)
  result.each(&block)
end
found?() click to toggle source
# File lib/shiftable/shifting_relation.rb, line 8
def found?
  result.any?
end
shift() { || ... } click to toggle source

@return result (once it is shifted)

# File lib/shiftable/shifting_relation.rb, line 17
def shift
  return false unless found?

  each do |record|
    record.send("#{column}=", to.id)
  end
  @run_save = yield if block_given?
  return result unless run_save

  run_save!
  result
end

Private Instance Methods

query() click to toggle source
# File lib/shiftable/shifting_relation.rb, line 32
def query
  base.where(column => from.id)
end