Class: RailsInfo::Data::RowSetPresenter

Inherits:
Presenter
  • Object
show all
Defined in:
app/presenters/rails_info/data/row_set_presenter.rb

Instance Method Summary collapse

Methods inherited from Presenter

#subject=

Constructor Details

#initialize(subject, options = {}) ⇒ RowSetPresenter

Returns a new instance of RowSetPresenter.



2
3
4
5
6
7
8
# File 'app/presenters/rails_info/data/row_set_presenter.rb', line 2

def initialize(subject, options = {})
  super(subject, options)
  
  options.assert_valid_keys(:row_set)
  
  @row_set = options[:row_set]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RailsInfo::Presenter

Instance Method Details

#headObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/presenters/rails_info/data/row_set_presenter.rb', line 14

def head
  title, group_by = nil, ''
  content =  :th, '', class: 'first'
  column_index = 0

  resource_columns(row_set, group_by).each do |column|
    style = column == group_by ? 'color:red;' : ''
    sub_content = column == group_by || title == nil ? column : link_to(column, uri_with_new_param('group_by_title[' + title + ']', column))
    content +=  :th, sub_content, style: style#, class: klass
    column_index += 1
  end
  
  content
end

#nameObject



10
11
12
# File 'app/presenters/rails_info/data/row_set_presenter.rb', line 10

def name
  row_set.first[:class].name.tableize.humanize
end

#objectsObject



29
30
31
# File 'app/presenters/rails_info/data/row_set_presenter.rb', line 29

def objects
  @objects ||= row_set.map{|object| ::RailsInfo::Data::ObjectPresenter.new(subject, object: object) }
end