Class: Effective::TableRows::Collection

Inherits:
Effective::TableRow show all
Defined in:
app/models/effective/table_rows/collection.rb

Instance Attribute Summary

Attributes inherited from Effective::TableRow

#builder, #name, #options, #template

Instance Method Summary collapse

Methods inherited from Effective::TableRow

#controller_namespace, #hint, #label, #label_content, #to_html, #value

Constructor Details

#initialize(name, collection, options, builder:) ⇒ Collection

Returns a new instance of Collection.



7
8
9
10
# File 'app/models/effective/table_rows/collection.rb', line 7

def initialize(name, collection, options, builder:)
  @collection = collection
  super(name, options, builder: builder)
end

Instance Method Details

#content ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'app/models/effective/table_rows/collection.rb', line 12

def content
  values = Array(value) - [nil, '']

  if values.length > 1
    values.map { |v| (:div, v) }.join.html_safe
  elsif values.length == 1
    values.first
  end

end