Class: Wice::FilterConditionsGeneratorInteger

Inherits:
FilterConditionsGenerator show all
Defined in:
lib/filter_conditions_generators.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from FilterConditionsGenerator

#initialize

Constructor Details

This class inherits a constructor from Wice::FilterConditionsGenerator

Instance Method Details

#generate_conditions(opts) ⇒ Object

@@handled_type = self



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/filter_conditions_generators.rb', line 97

def  generate_conditions(opts)   #:nodoc:
  unless opts.kind_of? Hash
    Wice.log "invalid parameters for the grid integer filter - must be a hash"
    return false
  end

  if !opts[:fr] || !(opts[:fr] =~ /\d/) || !opts[:to] || !(opts[:to] =~ /\d/)
    Wice.log "invalid parameters for the grid integer filter - either range limits are not supplied or they are not numeric"
    return false
  end

  @criteria.where(@field.name.to_sym.gt => opts[:fr].to_i)
  @criteria.where(@field.name.to_sym.lt => opts[:to].to_i)

  return true
end