Class: Adminable::Presenters::Entries

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/adminable/presenters/entries.rb

Constant Summary collapse

ENTRIES_LIMIT =
5

Instance Method Summary collapse

Constructor Details

#initialize(relation) ⇒ Entries

Returns a new instance of Entries.



23
24
25
26
27
28
# 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

Instance Method Details

#to_sObject



30
31
32
33
34
35
36
37
38
# 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