Sha256: bfc83948ce9782de53507e96a9b56bb58b2eb03bbc59fa12bd7079e69e5f8499

Contents?: true

Size: 964 Bytes

Versions: 4

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module GhostRb
  module Controllers
    # @author Rene Hernandez
    # @since 0.2
    class PostsController < BaseController
      attr_reader :endpoint, :resource_klass

      def initialize(client)
        super
        @endpoint = 'posts'
        @resource_klass = Resources::Post
      end

      def formats(formats)
        where(formats: formats)
      end

      private

      def raise_fetch_single_error(kvp, status, errors)
        key = kvp.key?(:id) ? :id : :slug
        message = "Unable to fetch post with #{key} = #{kvp[key]}"
        raise Errors::RequestError.new(message,
                                       status,
                                       errors)
      end

      def raise_fetch_list_error(status, errors)
        raise Errors::RequestError.new('Unable to fetch posts',
                                       status,
                                       errors)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ghost_rb-0.2.8 lib/ghost_rb/controllers/posts_controller.rb
ghost_rb-0.2.7 lib/ghost_rb/controllers/posts_controller.rb
ghost_rb-0.2.6 lib/ghost_rb/controllers/posts_controller.rb
ghost_rb-0.2.5 lib/ghost_rb/controllers/posts_controller.rb