Sha256: 41608b5d60be70c3a58aa50759ee2e68c8d9357c63d73a9261c98210842b9611

Contents?: true

Size: 841 Bytes

Versions: 11

Compression:

Stored size: 841 Bytes

Contents

class RailsInfo::Data::ObjectPresenter < ::RailsInfo::Presenter
  def initialize(subject, options = {})
    super(subject, options)
    
    options.assert_valid_keys(:object)
    
    @object = options[:object]
  end
  
  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
  
  private
  
  def object
    @object
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rails_info-0.1.1 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.1.0 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.9 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.8 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.7 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.6 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.5 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.4 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.3 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.2 app/presenters/rails_info/data/object_presenter.rb
rails_info-0.0.1 app/presenters/rails_info/data/object_presenter.rb