class ActiveInteraction::FilterColumn

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 `FilterColumn` for a specific type.

@param type [Symbol] A database column type.

@example

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

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

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

@return [FilterColumn]

# File lib/active_interaction/filter_column.rb, line 28
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 39
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 46
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 53
def text?
  type == :string
end