Class: ActiveInteraction::TimeFilter

Inherits:
AbstractDateTimeFilter show all
Defined in:
lib/active_interaction/filters/time_filter.rb

Overview

Since:

  • 1.0.0

Instance Attribute Summary

Attributes inherited from Filter

#filters, #name, #options

Instance Method Summary collapse

Methods inherited from Filter

#clean, #default, #default?, #desc, factory

Constructor Details

#initialize(name, options = {}, &block) ⇒ TimeFilter

Returns a new instance of TimeFilter.

Since:

  • 1.0.0



30
31
32
33
34
35
36
# File 'lib/active_interaction/filters/time_filter.rb', line 30

def initialize(name, options = {}, &block)
  if options.key?(:format) && klass != Time
    raise InvalidFilterError, 'format option unsupported with time zones'
  end

  super
end

Instance Method Details

#cast(value, _interaction) ⇒ Object

Since:

  • 1.0.0



38
39
40
41
42
43
44
45
# File 'lib/active_interaction/filters/time_filter.rb', line 38

def cast(value, _interaction)
  case value
  when Numeric
    klass.at(value)
  else
    super
  end
end

#database_column_typeObject

Since:

  • 1.0.0



47
48
49
# File 'lib/active_interaction/filters/time_filter.rb', line 47

def database_column_type
  :datetime
end