Class: TableCollectionRenderer::Header
- Inherits:
-
Object
- Object
- TableCollectionRenderer::Header
- Defined in:
- app/collection_renderers/table_collection_renderer.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#helper ⇒ Object
(also: #h)
Returns the value of attribute helper.
-
#resource_class ⇒ Object
Returns the value of attribute resource_class.
-
#view_context ⇒ Object
Returns the value of attribute view_context.
Instance Method Summary collapse
- #acts_as_list_actions(options = {}) ⇒ Object
- #acts_as_published_actions ⇒ Object
- #association(*args, &block) ⇒ Object
- #awesome_nested_set_actions(options = {}) ⇒ Object
- #column(attribute_name, options = {}) ⇒ Object
- #columns(*args) ⇒ Object
-
#initialize(resource_class, helper) ⇒ Header
constructor
A new instance of Header.
- #render(&block) ⇒ Object
- #timestamps ⇒ Object
- #userstamps ⇒ Object
Constructor Details
#initialize(resource_class, helper) ⇒ Header
Returns a new instance of Header.
6 7 8 9 10 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 6 def initialize(resource_class, helper) @resource_class, @helper = resource_class, helper @controller = helper.instance_variable_get('@_controller') @view_context = @controller.view_context end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
3 4 5 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 3 def controller @controller end |
#helper ⇒ Object Also known as: h
Returns the value of attribute helper.
3 4 5 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 3 def helper @helper end |
#resource_class ⇒ Object
Returns the value of attribute resource_class.
3 4 5 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 3 def resource_class @resource_class end |
#view_context ⇒ Object
Returns the value of attribute view_context.
3 4 5 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 3 def view_context @view_context end |
Instance Method Details
#acts_as_list_actions(options = {}) ⇒ Object
56 57 58 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 56 def acts_as_list_actions( = {}) column(:acts_as_list_actions) end |
#acts_as_published_actions ⇒ Object
52 53 54 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 52 def acts_as_published_actions column(:acts_as_published_actions) end |
#association(*args, &block) ⇒ Object
18 19 20 21 22 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 18 def association(*args, &block) = args. [:as] = :association column(*args, , &block) end |
#awesome_nested_set_actions(options = {}) ⇒ Object
60 61 62 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 60 def awesome_nested_set_actions( = {}) column(:awesome_nested_set_actions) end |
#column(attribute_name, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 24 def column(attribute_name, = {}) return column_with_sorting(attribute_name, ) if ransack_query.present? && .has_key?(:sortable) && [:sortable] != false label = if @resource_class.respond_to?(:human_attribute_name) @resource_class.human_attribute_name(attribute_name) else attribute_name end helper.content_tag(:th, label, id: "table-header-#{attribute_name}") end |
#columns(*args) ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 35 def columns(*args) _ = args. columns = *args || resource_class.attribute_names columns.collect do |name| column name end.join.html_safe end |
#render(&block) ⇒ Object
12 13 14 15 16 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 12 def render(&block) helper.content_tag(:tr) do block.call(self) end end |
#timestamps ⇒ Object
43 44 45 46 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 43 def column(:created_at, sortable: true) + column(:updated_at, sortable: true) end |
#userstamps ⇒ Object
48 49 50 51 |
# File 'app/collection_renderers/table_collection_renderer.rb', line 48 def userstamps column(:creator, sortable: true) + column(:updater, sortable: true) end |