class Pagy::Keyset::ActiveRecord

Keyset adapter for ActiveRecord

def after_latest = @set.where(after_latest_query, **@latest)

Filter out the already retrieved records
def after_latest = @set.where(after_latest_query, **@latest)

def apply_select

Append the missing keyset keys if the set is restricted by select
def apply_select
  @set.select(*@keyset.keys)
end

def extract_keyset

Extract the keyset from the set
def extract_keyset
  @set.order_values.each_with_object({}) do |node, keyset|
    keyset[node.value.name.to_sym] = node.direction
  end
end

def latest_from(latest_record) = latest_record.slice(*@keyset.keys)

Get the keyset attributes of the record
def latest_from(latest_record) = latest_record.slice(*@keyset.keys)

def select? = !@set.select_values.empty?

Set with selected columns?
def select? = !@set.select_values.empty?

def typecast_latest(latest)

Typecast the latest attributes
def typecast_latest(latest)
  @set.model.new(latest).slice(latest.keys)
      .to_hash.transform_keys(&:to_sym)
end