bookstore/app/presenters/books_presenter.rb
2021-03-22 03:16:29 +01:00

17 lines
312 B
Ruby

# frozen_string_literal: true
class BooksPresenter < SimpleDelegator
include ActiveSupport::NumberHelper
def price
super / 100
end
def price_with_currency
number_to_currency(price)
end
def authors
super.map { |author| "#{author.first_name} #{author.last_name}" }.join(', ')
end
end