Sha256: 0d091d67767003d33cc86e9145f07052491e5a834e4486e5d4ff9f429e513fe0
Contents?: true
Size: 698 Bytes
Versions: 8
Compression:
Stored size: 698 Bytes
Contents
module Hancock::SortField extend ActiveSupport::Concern module ClassMethods def sort_field(prefix = '') prefix = "#{prefix}_" unless prefix == '' if Hancock.mongoid? field "#{prefix}order".to_sym, type: Integer alias_method "#{prefix}sort", "#{prefix}order" scope "#{prefix}ordered".to_sym, -> { asc("#{prefix}order".to_sym) } scope "#{prefix}sorted".to_sym, -> { asc("#{prefix}order".to_sym) } end if Hancock.active_record? scope "#{prefix}ordered".to_sym, -> { order("#{prefix}order".to_sym => :asc) } scope "#{prefix}sorted".to_sym, -> { order("#{prefix}order".to_sym => :asc) } end end end end
Version data entries
8 entries across 8 versions & 1 rubygems