Class: Katalyst::Tables::Data

Inherits:
Object
  • Object
show all
Defined in:
app/components/katalyst/tables/data.rb

Instance Method Summary collapse

Constructor Details

#initialize(record:, column:) ⇒ Data

Returns a new instance of Data.



6
7
8
9
# File 'app/components/katalyst/tables/data.rb', line 6

def initialize(record:, column:)
  @record = record
  @column = column
end

Instance Method Details

#callObject Also known as: to_s



17
18
19
20
21
# File 'app/components/katalyst/tables/data.rb', line 17

def call
  ActionView::OutputBuffer.new.tap do |output|
    output << value.to_s
  end.to_s
end

#inspectObject



25
26
27
# File 'app/components/katalyst/tables/data.rb', line 25

def inspect
  "#<#{self.class.name} column: #{@column.inspect}, value: #{value.inspect}>"
end

#valueObject



11
12
13
14
15
# File 'app/components/katalyst/tables/data.rb', line 11

def value
  return @value if defined?(@value)

  @value = @record&.public_send(@column)
end