Skip to content

Latest commit

 

History

History
150 lines (96 loc) · 3.24 KB

CHANGELOG.md

File metadata and controls

150 lines (96 loc) · 3.24 KB

Changelog

Version 1.2.5

  • [feature] Added param? method to Search::Base (@rstankov)

Version 1.2.4

  • [feature] Added :with and block support to enum (@hschne)

Version 1.2.3

  • [fix] convert enum values to strings (@Postmodum37)

Version 1.2.2

  • [feature] Added SearchObject::Base#params= method, to reset search results (@rstankov)
  • [change] option :orderBy, enum: %(price date), now expects a method apply_order_by_x, instead of apply_orderBy_with_ (backward incompatible) (@rstankov)

Version 1.2.1

  • [feature] Added default: option to sort_by plugin (@rstankov)
class ProductSearch
  include SearchObject.module(:sorting)

  scope { Product.all }

  sort_by :name, :price, :created_at, default: 'price asc'
end

Version 1.2.0

  • [feature] Added enum plugin (@rstankov)
class ProductSearch
  include SearchObject.module(:enum)

  scope { Product.all }

  option :order, enum: %w(popular date)

  private

  # Gets called when order with 'popular' is given
  def apply_order_with_popular(scope)
    scope.by_popularity
  end

  # Gets called when order with 'date' is given
  def apply_order_with_date(scope)
    scope.by_date
  end

  # Gets called when invalid enum is given
  def handle_invalid_order(scope, invalid_value)
    scope
  end
end
  • [feature] Scope is executed in context of SearchObject::Base context (@rstankov)
class ProductSearch
 include SearchObject.module

 scope { @shop.products }

 def initialize(shop)
   @shop = shop
   super
 end
end

Version 1.1.3

  • [feature] Passing nil as scope in constructor, falls back to default scope (@rstankov)

Version 1.1.2

  • [fix] Fix a warning due to Rails 5 ActionController::Parameters not being a Hash (@rstankov)
  • [fix] Ensure sort_by prefixes with table_name. (@andreasklinger)

Version 1.1.1

  • [fix] Fix a bug in inheriting search objects (@avlazarov)

Version 1.1

  • [feature] Search objects now can be inherited (@rstankov)
class BaseSearch
  include SearchObject.module

  # ... options and configuration
end

class ProductSearch < BaseSearch
  scope { Product }
end
  • [feature] Use instance method for straight dispatch (@gsamokovarov)

    class ProductSearch
      include SearchObject.module
    
      scope { Product.all }
    
      option :date, with: :parse_dates
    
      private
    
      def parse_dates(scope, value)
        # some "magic" method to parse dates
      end
    end

Version 1.0

  • [feature] Added min_per_page and max_per_page to paging plugin (@rstankov)

  • [change] Default paging behaves more like 'kaminari' and 'will_paginate' by treating 1 page as 0 index (backward incompatible) (@rstankov)

  • [feature] Raise SearchObject::MissingScopeError when no scope is provided (@rstankov)

  • [change] Replace position arguments with Hash of options (backward incompatible) (@rstankov)

    - Search.new params[:f], params[:page]
    + Search.new filters: params[:f], page: params[:page]

Version 0.2

  • [feature] Added .results shortcut for new(*arg).results (@rstankov)

  • [fix] Fix wrong limit and offset in default paging (@rstankov)

Version 0.1

  • Initial release (@rstankov)