Class: Pageflow::Admin::AttributesTableRows

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/admin/attributes_table_rows.rb

Overview

Since:

  • 12.2

Instance Method Summary collapse

Constructor Details

#initializeAttributesTableRows

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AttributesTableRows.

Since:

  • 12.2



9
10
11
# File 'lib/pageflow/admin/attributes_table_rows.rb', line 9

def initialize
  @rows = {}
end

Instance Method Details

#for(resource_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 12.2



42
43
44
# File 'lib/pageflow/admin/attributes_table_rows.rb', line 42

def for(resource_name)
  @rows.fetch(resource_name, [])
end

#register(resource_name, name, options = {}) {|resource| ... } ⇒ Object

Insert an additional row into an attribute table.

Parameters:

  • resource_name (Symbol)

    Either :entry, :account or :theming.

  • name (Symbol)

    Name of the attribute to display.

  • options (Hash) (defaults to: {})

    Supports same options as ActiveAdmin::Views::AttributesTable#row, in addition to:

Options Hash (options):

  • :before (Symbol)

    Insert row before row with given name. Append to table if not found.

  • :after (Symbol)

    Insert row after row with given name. Append to table if not found.

Yield Parameters:

  • resource (ActiveRecord::Base)

    A block which is evaluated in the context of the Arbre template to render the contents of the cell.

Since:

  • 12.2



31
32
33
34
35
36
37
38
39
# File 'lib/pageflow/admin/attributes_table_rows.rb', line 31

def register(resource_name, name, options = {}, &block)
  @rows[resource_name] ||= []
  @rows[resource_name] << {
    name: name,
    block: block,
    options: options.except(:before, :after),
    **options.slice(:before, :after)
  }
end