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:



747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
# File 'lib/wice_grid.rb', line 747

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