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.

Since:

  • 1.2.0

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.

Since:

  • 1.2.0



41
42
43
# File 'lib/active_interaction/filter_column.rb', line 41

def initialize(type)
  @type = type
end

Instance Attribute Details

#limitnil (readonly)

Returns:

  • (nil)

Since:

  • 1.2.0



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

def limit
  @limit
end

#typeSymbol (readonly)

Returns:

  • (Symbol)

Since:

  • 1.2.0



12
13
14
# File 'lib/active_interaction/filter_column.rb', line 12

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:

Since:

  • 1.2.0



30
31
32
33
# File 'lib/active_interaction/filter_column.rb', line 30

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)

Since:

  • 1.2.0



48
49
50
# File 'lib/active_interaction/filter_column.rb', line 48

def number?
  [:integer, :float].include?(type)
end

#text?Boolean

Returns true if the column is of type :string.

Returns:

  • (Boolean)

Since:

  • 1.2.0



55
56
57
# File 'lib/active_interaction/filter_column.rb', line 55

def text?
  type == :string
end