Class: ActiveInteraction::Filter::Column

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) ⇒ Column

Returns a new instance of Column.

Parameters:

  • type (type)

    The database column type.



40
41
42
# File 'lib/active_interaction/filter/column.rb', line 40

def initialize(type)
  @type = type
end

Instance Attribute Details

#limitnil (readonly)

Returns:

  • (nil)


8
9
10
# File 'lib/active_interaction/filter/column.rb', line 8

def limit
  @limit
end

#typeSymbol (readonly)

Returns:

  • (Symbol)


11
12
13
# File 'lib/active_interaction/filter/column.rb', line 11

def type
  @type
end

Class Method Details

.intern(type) ⇒ Filter::Column

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

Examples:

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>

Parameters:

  • type (Symbol)

    A database column type.

Returns:



29
30
31
32
# File 'lib/active_interaction/filter/column.rb', line 29

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)


47
48
49
# File 'lib/active_interaction/filter/column.rb', line 47

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

#text?Boolean

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

Returns:

  • (Boolean)


54
55
56
# File 'lib/active_interaction/filter/column.rb', line 54

def text?
  type == :string
end