Sha256: 5b156c79a7c9ac9e038155754a460a0ec3c8ea2050e2fca6208637ad5d87f2ea

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

module Phlexi
  module Table
    module Components
      class DataColumn < Column
        def initialize(*, **, &block)
          super(*, **)
          @block = block
        end

        def header_cell
          SortableHeaderCell.new(label, sort_params:)
        end

        def data_cell(wrapped_object)
          if @block
            @block.call(wrapped_object, key)
          else
            field = wrapped_object.field(key)
            field.send(:"#{field.inferred_field_component}_tag")
          end
        end

        protected

        def sort_params
          options[:sort_params]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phlexi-table-0.0.5 lib/phlexi/table/components/data_column.rb
phlexi-table-0.0.4 lib/phlexi/table/components/data_column.rb
phlexi-table-0.0.3 lib/phlexi/table/components/data_column.rb