class RakutenApi::GenreSearch::Response

Public Class Methods

new(faraday_response = nil) click to toggle source
Calls superclass method RakutenApi::Base::Response::new
# File lib/rakuten_api/genre_search/response.rb, line 6
def initialize(faraday_response = nil)
  super(faraday_response)
end

Public Instance Methods

cache() click to toggle source
# File lib/rakuten_api/genre_search/response.rb, line 10
def cache
  @cache ||= {}
end
children() click to toggle source
# File lib/rakuten_api/genre_search/response.rb, line 31
def children
  return cache['children'] if cache.key? 'children'
  return [] unless @body.key? 'children'
  cache['children'] = [].tap do |result|
    @body["children"].each do |f|
      next unless f.include? 'child'
      result << Model.from_hash(f['child'])
    end
  end
end
current() click to toggle source
# File lib/rakuten_api/genre_search/response.rb, line 25
def current
  return cache['current'] if cache.key? 'current'
  return nil unless @body.key? 'current'
  cache['current'] = Model.from_hash(@body['current'])
end
parents() click to toggle source
# File lib/rakuten_api/genre_search/response.rb, line 14
def parents
  return cache['parents'] if cache.key? 'parents'
  return [] unless @body.key? 'parents'
  cache['parents'] = [].tap do |result|
    @body['parents'].each do |f|
      next unless f.include? 'parent'
      result << Model.from_hash(f['parent'])
    end
  end
end