Class: ActiveInteraction::FilterColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/active_interaction/filter_column.rb

Overview

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ FilterColumn

Returns a new instance of FilterColumn.

Parameters:

  • type (type)

    The database column type.



39
40
41
# File 'lib/active_interaction/filter_column.rb', line 39

def initialize(type)
  @type = type
end

Instance Attribute Details

#limitnil (readonly)

Returns:

  • (nil)


7
8
9
# File 'lib/active_interaction/filter_column.rb', line 7

def limit
  @limit
end

#typeSymbol (readonly)

Returns:

  • (Symbol)


10
11
12
# File 'lib/active_interaction/filter_column.rb', line 10

def type
  @type
end

Class Method Details

.intern(type) ⇒ FilterColumn

Find or create the ‘FilterColumn` for a specific type.

Examples:

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

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

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

Parameters:

  • type (Symbol)

    A database column type.

Returns:



28
29
30
31
# File 'lib/active_interaction/filter_column.rb', line 28

def intern(type)
  @columns ||= {}
  @columns[type] ||= new(type)
end

Instance Method Details

#number?Boolean

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

Returns:

  • (Boolean)


46
47
48
# File 'lib/active_interaction/filter_column.rb', line 46

def number?
  %i[integer float].include?(type)
end

#text?Boolean

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

Returns:

  • (Boolean)


53
54
55
# File 'lib/active_interaction/filter_column.rb', line 53

def text?
  type == :string
end