class ActiveInteraction::Filter::Column

A minimal implementation of an ‘ActiveRecord::ConnectionAdapters::Column`.

Attributes

limit[R]

@return [nil]

type[R]

@return [Symbol]

Public Class Methods

intern(type) click to toggle source

Find or create the ‘Filter::Column` for a specific type.

@param type [Symbol] A database column type.

@example

Filter::Column.intern(:string)
# => #<ActiveInteraction::Filter::Column:0x007feeaa649c @type=:string>

Filter::Column.intern(:string)
# => #<ActiveInteraction::Filter::Column:0x007feeaa649c @type=:string>

Filter::Column.intern(:boolean)
# => #<ActiveInteraction::Filter::Column:0x007feeab8a08 @type=:boolean>

@return [Filter::Column]

# File lib/active_interaction/filter/column.rb, line 29
def intern(type)
  @columns ||= {}
  @columns[type] ||= new(type)
end
new(type) click to toggle source

@param type [type] The database column type.

@private

# File lib/active_interaction/filter/column.rb, line 40
def initialize(type)
  @type = type
end

Public Instance Methods

number?() click to toggle source

Returns ‘true` if the column is either of type :integer or :float.

@return [Boolean]

# File lib/active_interaction/filter/column.rb, line 47
def number?
  %i[integer float].include?(type)
end
text?() click to toggle source

Returns ‘true` if the column is of type :string.

@return [Boolean]

# File lib/active_interaction/filter/column.rb, line 54
def text?
  type == :string
end