Sha256: 8e996c4b9c0482bcb6912da183095736b0f3229883c55b3af02f2afbd5059616
Contents?: true
Size: 949 Bytes
Versions: 1
Compression:
Stored size: 949 Bytes
Contents
module FortyFacets class RangeFilterDefintion < FilterDefinition class RangeFilter < Filter def build_scope return Proc.new { |base| base } if empty? Proc.new { |base| base.where("#{filter_definition.model_field} >= ? AND #{filter_definition.model_field} <= ? ", min_value, max_value ) } end def min_value return nil if empty? value.split(' - ').first end def max_value return nil if empty? value.split(' - ').last end def absolute_interval @abosultes ||= without.result.select("min(#{filter_definition.model_field}) as min, max(#{filter_definition.model_field}) as max").first end def absolute_min absolute_interval.min end def absolute_max absolute_interval.max end end def build_filter(search_instance, value) RangeFilter.new(self, search_instance, value) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
forty_facets-0.0.4 | lib/forty_facets/filter/range_filter_definition.rb |