Class: CafeCar::ActiveRecord::RelationPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/cafe_car/active_record/relation_presenter.rb

Instance Method Summary collapse

Instance Method Details

#eachObject



8
# File 'app/presenters/cafe_car/active_record/relation_presenter.rb', line 8

def each = object.each { yield present(_1) }

#human(attribute, **options) ⇒ Object



4
5
6
# File 'app/presenters/cafe_car/active_record/relation_presenter.rb', line 4

def human(attribute, **options)
  object.human_attribute_name(attribute, options)
end

#to_htmlObject



10
11
12
13
14
# File 'app/presenters/cafe_car/active_record/relation_presenter.rb', line 10

def to_html
  objects = object.to_a.uniq
  objects = objects.sort_by(&:sort_key) if objects.first.respond_to?(:sort_key)
  present objects, count: object.count, **@options
end