Class: RailsInfo::Data::ObjectPresenter
- Defined in:
- app/presenters/rails_info/data/object_presenter.rb
Instance Method Summary collapse
-
#initialize(subject, options = {}) ⇒ ObjectPresenter
constructor
A new instance of ObjectPresenter.
- #row ⇒ Object
Methods inherited from Presenter
Constructor Details
#initialize(subject, options = {}) ⇒ ObjectPresenter
Returns a new instance of ObjectPresenter.
2 3 4 5 6 7 8 |
# File 'app/presenters/rails_info/data/object_presenter.rb', line 2 def initialize(subject, = {}) super(subject, ) .assert_valid_keys(:object) @object = [:object] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RailsInfo::Presenter
Instance Method Details
#row ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/presenters/rails_info/data/object_presenter.rb', line 10 def row content = content_tag :td, class: 'first' do check_box_tag "data[]", "#{object[:class].name};#{object['id']}", false, id: "#{object[:class].name.tableize}-#{object['id']}" end object[:class].columns.each do |column| value = object[column.name] if ['string', 'text'].include?(column.type.to_s) text = value.present? && value.length > 20 ? "#{value[0,20]}..." : value value = content_tag :span, text, title: value end content += content_tag :td, value end content end |