Sha256: b10e10b6becc6f218103d237bded657377ca47d5254f8df662cac756deeceafc
Contents?: true
Size: 1.07 KB
Versions: 12
Compression:
Stored size: 1.07 KB
Contents
# See Pagy API documentation: https://ddnexus.github.io/pagy/docs/api/keyset # frozen_string_literal: true class Pagy class Keyset # Keyset adapter for ActiveRecord class ActiveRecord < Keyset protected # Get the keyset attributes of the record def latest_from(latest_record) = latest_record.slice(*@keyset.keys) # 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 # Filter out the already retrieved records def after_latest = @set.where(after_latest_query, **@latest) # Append the missing keyset keys if the set is restricted by select def apply_select @set.select(*@keyset.keys) end # Set with selected columns? def select? = !@set.select_values.empty? # Typecast the latest attributes def typecast_latest(latest) @set.model.new(latest).slice(latest.keys) .to_hash.transform_keys(&:to_sym) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems