Class: Katalyst::Tables::Suggestions::DatabaseValue

Inherits:
Base
  • Object
show all
Defined in:
app/models/katalyst/tables/suggestions/database_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#eql?, #hash, #inspect

Constructor Details

#initialize(name:, type:, model:, column:, value:) ⇒ DatabaseValue

Returns a new instance of DatabaseValue.



11
12
13
14
15
16
17
18
# File 'app/models/katalyst/tables/suggestions/database_value.rb', line 11

def initialize(name:, type:, model:, column:, value:)
  super(value)

  @attribute_type = type
  @model = model
  @column = column
  @name = name
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



7
8
9
# File 'app/models/katalyst/tables/suggestions/database_value.rb', line 7

def column
  @column
end

#modelObject (readonly)

Returns the value of attribute model.



7
8
9
# File 'app/models/katalyst/tables/suggestions/database_value.rb', line 7

def model
  @model
end

Instance Method Details

#typeObject



20
21
22
# File 'app/models/katalyst/tables/suggestions/database_value.rb', line 20

def type
  :database_value
end

#valueObject



26
27
28
29
30
31
32
# File 'app/models/katalyst/tables/suggestions/database_value.rb', line 26

def value
  if @attribute_type.multiple? && @value.is_a?(Array) && @value.length == 1
    to_param(@value.first)
  else
    to_param(@value)
  end
end