class ButterCMS::PostsFetchService

Attributes

request_options[R]

Public Class Methods

new(request_options) click to toggle source
# File lib/butter_cms/posts_fetch_service.rb, line 3
def initialize(request_options)
  @request_options = request_options
end

Public Instance Methods

posts() click to toggle source

Returns array of post objects with the associated records included

@return [Array<ButterCMS::Post>]

# File lib/butter_cms/posts_fetch_service.rb, line 10
def posts
  parser.posts.map do |post_attributes|
    ::ButterCMS::Parsers::PostObject.call(post_attributes)
  end
end

Private Instance Methods

parser() click to toggle source
# File lib/butter_cms/posts_fetch_service.rb, line 31
def parser
  @parser ||= ::ButterCMS::Parsers::Posts.new(response)
end
response() click to toggle source
# File lib/butter_cms/posts_fetch_service.rb, line 27
def response
  ::ButterCMS::Requests::Get.call("posts", request_options)
end