Module: Wice::Columns::CommonRailsDateDatetimeConditionsGeneratorMixin

Included in:
ConditionsGeneratorColumnRailsDateHelper, ConditionsGeneratorColumnRailsDatetimeHelper
Defined in:
lib/wice/columns/common_rails_date_datetime_conditions_generator_mixin.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#generate_conditions(table_alias, opts) ⇒ Object

:nodoc:



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wice/columns/common_rails_date_datetime_conditions_generator_mixin.rb', line 5

def generate_conditions(table_alias, opts)   #:nodoc:
  conditions = [[]]
  if opts[:fr]
    conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} >= ? "
    conditions << opts[:fr].to_date
  end

  if opts[:to]
    conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} <= ? "
    conditions << (opts[:to].to_date + 1)
  end

  return false if conditions.size == 1

  conditions[0] = conditions[0].join(' and ')
  conditions
end