Class: ActiveInteraction::AbstractNumericFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/active_interaction/filters/abstract_numeric_filter.rb

Overview

Since:

  • 0.1.0

Direct Known Subclasses

FloatFilter, IntegerFilter

Instance Attribute Summary

Attributes inherited from Filter

#filters, #name, #options

Instance Method Summary collapse

Methods inherited from Filter

#clean, #default, factory, #has_default?, inherited, #initialize, slug

Constructor Details

This class inherits a constructor from ActiveInteraction::Filter

Instance Method Details

#cast(value) ⇒ Object

Since:

  • 0.1.0



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_interaction/filters/abstract_numeric_filter.rb', line 4

def cast(value)
  case value
  when klass
    value
  when Numeric, String
    begin
      send(klass.name, value)
    rescue ArgumentError
      super
    end
  else
    super
  end
end