Class: Component::CollectionTable

Inherits:
Base
  • Object
show all
Defined in:
app/components/component/collection_table.rb

Constant Summary collapse

SIZE_MAP =
{
  default: nil,
  small:   :sm
}

Instance Method Summary collapse

Methods inherited from Base

#perform

Constructor Details

#initialize(*args) ⇒ CollectionTable

Returns a new instance of CollectionTable.



8
9
10
11
12
13
# File 'app/components/component/collection_table.rb', line 8

def initialize(*args)
  super
  @columns        = {}
  @collection     = @options.delete(:collection)
  @resource_class = @options.delete(:resource_class) || @collection.first.class
end

Instance Method Details

#association(name, options = {}, &block) ⇒ Object



25
26
27
28
# File 'app/components/component/collection_table.rb', line 25

def association(name, options = {}, &block)
  options.reverse_merge!(block: block) if block_given?
  @columns[name] = options
end

#column(name, options = {}, &block) ⇒ Object



15
16
17
18
# File 'app/components/component/collection_table.rb', line 15

def column(name, options = {}, &block)
  options.reverse_merge!(block: block) if block_given?
  @columns[name] = options
end

#timestamps(options = {}) ⇒ Object



20
21
22
23
# File 'app/components/component/collection_table.rb', line 20

def timestamps(options = {})
  column(:created_at, options)
  column(:updated_at, options)
end