Sha256: 2fa7c8c1d764a04dce4dd0dad2daf07b241f7b21bb67815add0288e197982d0c

Contents?: true

Size: 268 Bytes

Versions: 7

Compression:

Stored size: 268 Bytes

Contents

module ActiveHashRelation::SortFilters
  def apply_sort(resource, params, model = nil)
    if model.columns.map(&:name).include?(params[:property])
      resource = resource.order(params[:property] => (params[:order] || :desc) )
    end

    return resource
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
active_hash_relation-1.0.4 lib/active_hash_relation/sort_filters.rb
active_hash_relation-1.0.3 lib/active_hash_relation/sort_filters.rb
active_hash_relation-1.0.2 lib/active_hash_relation/sort_filters.rb
active_hash_relation-1.0.1 lib/active_hash_relation/sort_filters.rb
active_hash_relation-1.0.0 lib/active_hash_relation/sort_filters.rb
active_hash_relation-0.0.3 lib/active_hash_relation/sort_filters.rb
active_hash_relation-0.0.2 lib/active_hash_relation/sort_filters.rb