Class: Wice::Columns::ConditionsGeneratorColumnString

Inherits:
ConditionsGeneratorColumn show all
Defined in:
lib/wice/columns/column_string.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from ConditionsGeneratorColumn

#initialize

Constructor Details

This class inherits a constructor from Wice::Columns::ConditionsGeneratorColumn

Instance Method Details

#generate_conditions(table_alias, opts) ⇒ Object

:nodoc:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/wice/columns/column_string.rb', line 66

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?
    return false
  end
  [
    " #{negation}  #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} #{::Wice.get_string_matching_operators(@column_wrapper.model)} ?",
    '%' + string_fragment + '%'
  ]
end