summaryrefslogtreecommitdiff
path: root/app/controllers/api/v2/cakes_controller.rb
blob: c310323da65c3f30cdb1cefad09837da4302cb6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Api
  module V2
    class CakesController < ApplicationController
      attr_reader :repository

      def initialize(repository = Spank::IOC.resolve(:cakes))
        @repository = repository
        super()
      end

      def index
        @cakes = paginate(repository.search_with(params).includes(:category))
        @photos = Photo.processed.where(imageable_id: @cakes.pluck(:id))
      end

      def show(id = params[:id])
        @cake = repository.find(id)
      end
    end
  end
end