Class: Wice::FilterConditionsGeneratorString

Inherits:
FilterConditionsGenerator show all
Defined in:
lib/wice_grid.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(table_alias, opts) ⇒ Object

:nodoc:


736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
# File 'lib/wice_grid.rb', line 736

def generate_conditions(table_alias, opts)   #:nodoc:
  if opts.kind_of? String
    string_fragment = opts
    negation = ''
  elsif (opts.kind_of? Hash) && opts.has_key?(:v)
    string_fragment = opts[:v]
    negation = opts[:n] == '1' ? 'NOT' : ''
  else
    Wice.log "invalid parameters for the grid string filter - must be a string: #{opts.inspect} or a Hash with keys :v and :n"
    return false
  end
  if string_fragment.empty?
    Wice.log "invalid parameters for the grid string filter - empty string"
    return false
  end
  [" #{negation}  #{@column.alias_or_table_name(table_alias)}.#{@column.name} #{::Wice.get_string_matching_operators(@column.model_klass)} ?",
      '%' + string_fragment + '%']
end