/ ruby

SearchObject 1.1

Today I released version 1.1 of my Search Object gem. It has two major new features.

Using instance method for straight dispatch

Suggested and developed by Genadi Samokovarov:

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

Classes mixed with SearchObject can be inherited

I had this setting on a branch for a long time. In one of the projects I worked on it would have been usefull to have a search base object:

class BaseSearch
  include SearchObject.module

  # ... options and configuration
end
 
# and used as 
class ProductSearch < BaseSearch
  scope { Product }
end

Its implementation actually might push me into an interesting refactoring.

Other minor features

  • I added Rubocop for verifying the project
  • I started testing against Ruby 2.2
  • I stopped testing against Ruby 1.9