Sha256: 6f4032533114a4bde434f73f696f04ab612967917f96fd6619d0d5e9d8f1eb5f
Contents?: true
Size: 811 Bytes
Versions: 2
Compression:
Stored size: 811 Bytes
Contents
module ActiveHashRelation::SortFilters def apply_sort(resource, params, model = nil) if params.is_a? Array params.each do |param_item| resource = apply_hash_sort(resource, param_item, model) end else resource = apply_hash_sort(resource, params, model) end return resource end def apply_hash_sort(resource, params, model = nil) if not params[:property].blank? if model.columns.map(&:name).include?(params[:property].to_s) resource = resource.order(params[:property] => (params[:order] || :desc) ) end else params.each do |property, order| if model.columns.map(&:name).include?(property.to_s) resource = resource.order(property => (order || :desc) ) end end end return resource end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_hash_relation-1.4.1 | lib/active_hash_relation/sort_filters.rb |
active_hash_relation-1.4.0 | lib/active_hash_relation/sort_filters.rb |