Last active
January 19, 2016 12:06
-
-
Save sclinede/55ba61be0c73a12c140e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Public: Виджет 'Акции компании на главной ск' | |
# | |
# Возвращает публикуемые, не истекшие, одобренные или на модерации, отмеченные for_home_page, | |
# наиболее свежие по дате создания акции | |
# | |
# Examples | |
# | |
# presenter 'apress/deals/front/offer', :latest_company_offers, company, {limit: 3} | |
# | |
# company - Company - компания, акции которой необходимо получить | |
# options - Hash, опции | |
# :limit - Integer - кол-во акций (по умолчанию 3) | |
# | |
# Returns String - отрендеренный шаблон | |
# | |
def latest_company_offers(company, options = {}) | |
@company = company | |
options = {limit: 3}.merge!(options) | |
view.cache( | |
company_offers_cache_key(options), | |
expires_in: 90.minutes, | |
tags: {latest_company_offers: company.id} | |
) do | |
offers = LatestCompanyOffersFinder.new(company: company, per_page: options[:limit]).call | |
@offers = Apress::Application::PaginatingDecorator.decorate(offers, with: OfferDecorator) | |
view.safe_concat(view.render 'apress/deals/front/presenters/offer/latest_company_offers', presenter: self, | |
options: options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment