class Adminable::Presenters::Entries

Constants

ENTRIES_LIMIT

Attributes

collection[RW]
relation[RW]

Public Class Methods

new(relation) click to toggle source
# File lib/adminable/presenters/entries.rb, line 23
def initialize(relation)
  @relation = relation
  @collection = relation.all.map do |entry|
    Adminable::Presenters::Entry.new(entry)
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/adminable/presenters/entries.rb, line 30
def to_s
  string = collection.first(ENTRIES_LIMIT).map do |entry|
    view.link_to(entry.to_name, edit_polymorphic_path(entry))
  end

  string << and_more_tag if collection_size_residue > 0

  string.join(', ').html_safe
end

Private Instance Methods

and_more_tag() click to toggle source
# File lib/adminable/presenters/entries.rb, line 48
def and_more_tag
  view.content_tag(
    :span,
    I18n.t('adminable.ui.and_more', size: collection_size_residue),
    class: 'text-muted'
  )
end
collection_size_residue() click to toggle source
# File lib/adminable/presenters/entries.rb, line 44
def collection_size_residue
  @collection_residue ||= collection.size - ENTRIES_LIMIT
end