Sha256: 896bb845dffeed0129dfe2a0aa38e16dd817f0c4c6cea67789b29c796f343531
Contents?: true
Size: 732 Bytes
Versions: 1
Compression:
Stored size: 732 Bytes
Contents
require 'hikari' require 'active_support/concern' module Hikari module ActiveRecord extend ActiveSupport::Concern included do def self.sort(sort_param, default_order = nil) parser = ::Hikari::Parser.new(sort_param, default_order) if self.column_names.include?(parser.field) if parser.asc? order( parser.field ) else order( parser.field ).reverse_order end elsif self.respond_to?(parser.field) if parser.asc? self.send(parser.field) else self.send(parser.field).reverse_order end else # do nothing, log error all end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hikari-0.5.0 | lib/hikari/active_record.rb |