Class: RestaurantCpt::Cell::Card
- Inherits:
-
Trailblazer::Cell
- Object
- Trailblazer::Cell
- RestaurantCpt::Cell::Card
- Defined in:
- app/concepts/restaurant_cpt/cell/card.rb
Overview
Responsible to decorate restaurants to be displayed in card mode
Instance Method Summary collapse
- #cache_id ⇒ Object
- #default_page ⇒ Object
- #default_per_page ⇒ Object
- #page ⇒ Object
- #per_page ⇒ Object
- #restaurants ⇒ Object
- #show ⇒ Object
Instance Method Details
#cache_id ⇒ Object
25 26 27 |
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 25 def cache_id [:cache_id] || raise('please define cache_id options') end |
#default_page ⇒ Object
37 38 39 |
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 37 def default_page DEFAULT_PAGE end |
#default_per_page ⇒ Object
41 42 43 |
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 41 def default_per_page DEFAULT_PER_PAGE end |
#page ⇒ Object
29 30 31 |
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 29 def page [:page] || DEFAULT_PAGE end |
#per_page ⇒ Object
33 34 35 |
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 33 def per_page ([:per_page] || DEFAULT_PER_PAGE).to_i end |
#restaurants ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 17 def restaurants @restaurants ||= begin r = model || raise('Restaurants is not defined') raise('pass lambda for model') unless r.respond_to?(:call) r.call.page(page).per(per_page) end end |
#show ⇒ Object
12 13 14 15 |
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 12 def show ActiveModel::Serializer::CollectionSerializer.new(restaurants, serializer: Websites::RestaurantSliderSerializer).to_json end |