Class: RestaurantCpt::Cell::Card

Inherits:
Trailblazer::Cell
  • Object
show all
Defined in:
app/concepts/restaurant_cpt/cell/card.rb

Overview

Responsible to decorate restaurants to be displayed in card mode

Instance Method Summary collapse

Instance Method Details

#cache_idObject



25
26
27
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 25

def cache_id
  options[:cache_id] || raise('please define cache_id options')
end

#default_pageObject



37
38
39
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 37

def default_page
  DEFAULT_PAGE
end

#default_per_pageObject



41
42
43
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 41

def default_per_page
  DEFAULT_PER_PAGE
end

#pageObject



29
30
31
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 29

def page
  options[:page] || DEFAULT_PAGE
end

#per_pageObject



33
34
35
# File 'app/concepts/restaurant_cpt/cell/card.rb', line 33

def per_page
  (options[:per_page] || DEFAULT_PER_PAGE).to_i
end

#restaurantsObject



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

#showObject



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