class Sorted::ActionView::Builder

Attributes

params[R]

Public Class Methods

new(order, params = {}) click to toggle source
# File lib/sorted/actionview/builder.rb, line 8
def initialize(order, params = {})
  @sort = ::Sorted::URIQuery.parse(params.delete(:sort))
  @order = ::Sorted::SQLQuery.parse(order)
  @params = params
  set = @order.direction_intersect(@sort)
  @params[:sort] = ::Sorted::URIQuery.encode(set)
end

Public Instance Methods

css() click to toggle source
# File lib/sorted/actionview/builder.rb, line 16
def css
  if @sort.keys.include? @order.keys.first
    "sorted #{@sort.assoc(@order.keys.first).last}"
  else
    'sorted'
  end
end