Sha256: 6756a6ea3e198ac6c94dbe50f01627a2f75fb27f2016d0dbd55a1a77f8bb3b3e
Contents?: true
Size: 715 Bytes
Versions: 20
Compression:
Stored size: 715 Bytes
Contents
# frozen_string_literal: true module Effective module TableRows class Collection < Effective::TableRow def initialize(name, collection, options, builder:) @collection = collection super(name, options, builder: builder) end def content values = Array(value) - [nil, ''] if values.length > 1 values.map { |v| content_tag(:div, item_content(v)) }.join.html_safe elsif values.length == 1 item_content(values.first) end end def item_content(value) item = @collection.find { |k, v| (k && k == value) || (v && v == value) || k.try(:id) == value } (item || value).to_s end end end end
Version data entries
20 entries across 20 versions & 1 rubygems