Class: ProductGroupSearch::DateField

Inherits:
NumberField show all
Defined in:
lib/nimbleshop/product_group_search/date_field.rb

Instance Attribute Summary

Attributes inherited from BaseField

#condition

Instance Method Summary collapse

Methods inherited from NumberField

#valid_operators

Methods inherited from BaseField

#initialize, #valid_operator?, #where

Constructor Details

This class inherits a constructor from ProductGroupSearch::BaseField

Instance Method Details

#coerced_valueObject



3
4
5
# File 'lib/nimbleshop/product_group_search/date_field.rb', line 3

def coerced_value
  Date.strptime(value.try(:to_s), "%d/%m/%Y")
end

#valid_value_data_type?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
# File 'lib/nimbleshop/product_group_search/date_field.rb', line 7

def valid_value_data_type?
  begin
    Date.strptime(value.try(:to_s), "%d/%m/%Y")
    true
  rescue
    false
  end
end