Class: ActiveAdmin::Views::AttributesTable

Inherits:
Component show all
Defined in:
lib/active_admin/views/components/attributes_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

#initialize, #tag_name

Constructor Details

This class inherits a constructor from ActiveAdmin::Component

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



7
8
9
# File 'lib/active_admin/views/components/attributes_table.rb', line 7

def resource
  @resource
end

Instance Method Details

#build(record, *attrs) ⇒ Object



9
10
11
12
13
14
# File 'lib/active_admin/views/components/attributes_table.rb', line 9

def build(record, *attrs)
  @record = record
  super(:for => @record)
  @table = table
  rows(*attrs)
end

#row(attr, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/active_admin/views/components/attributes_table.rb', line 20

def row(attr, &block)
  @table << tr do
    th do
      header_content_for(attr)
    end
    td do
      content_for(block || attr)
    end
  end
end

#rows(*attrs) ⇒ Object



16
17
18
# File 'lib/active_admin/views/components/attributes_table.rb', line 16

def rows(*attrs)
  attrs.each {|attr| row(attr) }
end