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.

Since:

  • 1.2.0



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

def initialize(type)
  @type = type
end

Instance Attribute Details

#limitnil (readonly)

Since:

  • 1.2.0



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

def limit
  @limit
end

#typeSymbol (readonly)

Since:

  • 1.2.0



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

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>

Since:

  • 1.2.0



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

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.

Since:

  • 1.2.0



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

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

#text?Boolean

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

Since:

  • 1.2.0



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

def text?
  type == :string
end