class CursorPager::OrderValues
OrderValue
collection wrapper.
Public Class Methods
from_relation(relation)
click to toggle source
A relation's order_values can either be an empty array, an array including just one string, or an array of arel ordering nodes.
# File lib/cursor_pager/order_values.rb, line 15 def self.from_relation(relation) arel_order_values = relation.order_values.uniq.reject(&:blank?) collection = arel_order_values.flat_map do |value| case value when Arel::Nodes::Ordering OrderValue.from_arel_node(relation, value) when String OrderValue.from_order_string(relation, value) end end new(collection) end
new(collection = [])
click to toggle source
# File lib/cursor_pager/order_values.rb, line 29 def initialize(collection = []) @collection = collection end
Public Instance Methods
direction()
click to toggle source
# File lib/cursor_pager/order_values.rb, line 33 def direction @collection.first&.direction end
order_string()
click to toggle source
# File lib/cursor_pager/order_values.rb, line 37 def order_string @collection.map(&:order_string).join(", ") end