Module: Capybara::ActiveAdmin::Finders::Table
- Included in:
- Capybara::ActiveAdmin::Finders
- Defined in:
- lib/capybara/active_admin/finders/table.rb
Overview
Finders for table_for, it’s rows and cells.
Instance Method Summary collapse
- #find_table_cell(column) ⇒ Object
- #find_table_row(id: nil, index: nil) ⇒ Object
- #within_table_cell(name) { ... } ⇒ Object
- #within_table_for(resource_name = nil) { ... } ⇒ Object
-
#within_table_row(id: nil, index: nil) { ... } ⇒ Object
id [String, Integer, nil] record ID.
Instance Method Details
#find_table_cell(column) ⇒ Object
43 44 45 46 |
# File 'lib/capybara/active_admin/finders/table.rb', line 43 def find_table_cell(column) selector = table_cell_selector(column) find(selector) end |
#find_table_row(id: nil, index: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/capybara/active_admin/finders/table.rb', line 24 def find_table_row(id: nil, index: nil) raise ArgumentError, "can't use both :id and :index" if id && index raise ArgumentError, 'must provide :id or :index' if id.nil? && index.nil? if id selector = table_row_selector(id) return find(selector) end selector = table_row_selector(nil) find_all(selector, minimum: index + 1)[index] end |
#within_table_cell(name) { ... } ⇒ Object
38 39 40 41 |
# File 'lib/capybara/active_admin/finders/table.rb', line 38 def within_table_cell(name) cell = find_table_cell(name) within(cell) { yield } end |
#within_table_for(resource_name = nil) { ... } ⇒ Object
10 11 12 13 14 |
# File 'lib/capybara/active_admin/finders/table.rb', line 10 def within_table_for(resource_name = nil) selector = table_selector(resource_name) within(selector) { yield } end |
#within_table_row(id: nil, index: nil) { ... } ⇒ Object
id [String, Integer, nil] record ID. index [Integer] row index in table (starts with 0).
19 20 21 22 |
# File 'lib/capybara/active_admin/finders/table.rb', line 19 def within_table_row(id: nil, index: nil) row = find_table_row(id: id, index: index) within(row) { yield } end |