Sha256: 4872e06a41a0ab8f9f5e4472a140fb1c8d4ef13a0a26248249cddbcd96fd37f5

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

module RademadeAdmin
  module Search
    class ListConditions < Abstract

      protected

      def where
        where_conditions = super
        where_conditions[:and] = @params.slice(*@origin_fields)
        where_conditions
      end

      def order
        field = @params[:sort] || default_order_field
        direction = @params[:direction] || :asc
        [{field => direction}]
      end

      def page
        @params[:page] || 1
      end

      def per_page
        @params[:paginate] || 20
      end

      private

      def default_order_field
        @origin_fields.include?('position') ? :position : :id
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rademade_admin-0.0.1 app/services/search/conditions/list.rb