Sha256: 77dd7c8ce6c3c4755e93e393189745af46097899e6f9ddd584ca036564fc9418
Contents?: true
Size: 1.08 KB
Versions: 8
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module Katalyst module Tables class BodyCellComponent < ViewComponent::Base # :nodoc: include Katalyst::HtmlAttributes attr_reader :record def initialize(table, record, attribute, heading: false, **html_attributes) super(**html_attributes) @table = table @record = record @attribute = attribute @type = heading ? :th : :td end def before_render # fallback if no content block is given with_content(value.to_s) unless content? end def call content # ensure content is set before rendering options content_tag(@type, content, **html_attributes) end # @return the object for this row. def object @record end def value @record.public_send(@attribute) end def inspect "#<#{self.class.name} attribute: #{@attribute.inspect}, value: #{value.inspect}>" end # Backwards compatibility with tables 1.0 alias_method :options, :html_attributes= end end end
Version data entries
8 entries across 8 versions & 1 rubygems