bruz/bookshelf-delivery-example

View on GitHub
apps/api/controllers/books/index.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Api::Controllers::Books
  class Index
    include Api::Action

    expose :books

    def call(_)
      books = BookRepository.all
      hashes = books.map do |book|
        Api::Representers::Book.new(book).to_hash
      end

      self.status = 200
      self.body = { books: hashes }.to_json
    end
  end
end