Class: SimpleModelView::CollectionTableRowBuilder

Inherits:
Object
  • Object
show all
Includes:
BuilderHelpers, TemplateHelpers
Defined in:
lib/simple_model_view/collection_table_row_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BuilderHelpers

#format

Methods included from TemplateHelpers

#blank_span, #block_concat, #merge_html_attrs

Constructor Details

#initialize(template, object, *_args, formatter: SimpleModelView.formatter) ⇒ CollectionTableRowBuilder

Returns a new instance of CollectionTableRowBuilder.



8
9
10
11
12
# File 'lib/simple_model_view/collection_table_row_builder.rb', line 8

def initialize(template, object, *_args, formatter: SimpleModelView.formatter)
  @template = template
  @object = object
  @formatter = formatter
end

Instance Attribute Details

#formatterObject (readonly)

Returns the value of attribute formatter.



14
15
16
# File 'lib/simple_model_view/collection_table_row_builder.rb', line 14

def formatter
  @formatter
end

#objectObject (readonly)

Returns the value of attribute object.



14
15
16
# File 'lib/simple_model_view/collection_table_row_builder.rb', line 14

def object
  @object
end

#templateObject (readonly)

Returns the value of attribute template.



14
15
16
# File 'lib/simple_model_view/collection_table_row_builder.rb', line 14

def template
  @template
end

Instance Method Details

#actions(*_args) ⇒ Object



24
25
26
27
28
# File 'lib/simple_model_view/collection_table_row_builder.rb', line 24

def actions(*_args)
  template.(:td, nil) do
    yield object if block_given?
  end
end

#column(attr_name, **options, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/simple_model_view/collection_table_row_builder.rb', line 16

def column(attr_name, **options, &block)
  render_data = prepare_render_data(attr_name: attr_name, options: options)

  render_column render_data[:wrapper_html] do
    render_value render_data, options, &block
  end
end