Sha256: 1ec724b29c394ea5fa9e8c125596751cb20e35b0361280a35ceed301a06b8835

Contents?: true

Size: 728 Bytes

Versions: 12

Compression:

Stored size: 728 Bytes

Contents

module FortyFacets
  class CustomFilterDefinition < FilterDefinition
    class CustomFilter < Filter
      def build_scope
        return Proc.new { |base| base } # the custom filter doesn alter the query at all
                                        # but you can use it's state to modify the base_scope
                                        # in your controller
      end

      def set(new_value)
        new_params = search_instance.params || {}

        new_params[definition.request_param] = new_value
        search_instance.class.new_unwrapped(new_params, search_instance.root)
      end

    end

    def build_filter(search_instance, value)
      CustomFilter.new(self, search_instance, value)
    end

  end
end


Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
forty_facets-0.2.1 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.2 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.9.1 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.9.0 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.8.9 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.8 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.7 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.6 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.5 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.4 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.3 lib/forty_facets/filter/custom_filter_definition.rb
forty_facets-0.1.2 lib/forty_facets/filter/custom_filter_definition.rb