class Babik::Selection::Operation::DateOperation

Each one of the operations over date fields (date, year, month, day, etc.)

Constants

HAS_OPERATOR

Public Class Methods

new(field, operator, value) click to toggle source
Calls superclass method Babik::Selection::Operation::Base::new
# File lib/babik/queryset/lib/selection/operation/date.rb, line 24
def initialize(field, operator, value)
  assert_dbms
  operator ||= 'equal'
  @operator = operator
  # In the left-hand of the main operator lies the sql_function
  # that will extract the desired part of the datetime
  # This function represents the field as #field, not as ?field
  # to avoid having replacement issues
  code_for_sql_function = sql_function
  main_operation = Base.factory(code_for_sql_function, operator, value)
  # Replacement mechanism only understand ?field and not #field,
  # so replace #field for ?field and let it work
  main_operation_sql_code = main_operation.sql_operation.sub('#field', '?field')
  super(field, main_operation_sql_code, value)
end

Public Instance Methods

sql_function() click to toggle source
# File lib/babik/queryset/lib/selection/operation/date.rb, line 40
def sql_function
  raise NotImplementedError
end