Class: RakutenApi::GenreSearch::Response
Instance Attribute Summary
#body, #status
Instance Method Summary
collapse
#error?, #error_message, #success?
Constructor Details
#initialize(faraday_response = nil) ⇒ Response
Returns a new instance of Response.
6
7
8
|
# File 'lib/rakuten_api/genre_search/response.rb', line 6
def initialize(faraday_response = nil)
super(faraday_response)
end
|
Instance Method Details
#cache ⇒ Object
10
11
12
|
# File 'lib/rakuten_api/genre_search/response.rb', line 10
def cache
@cache ||= {}
end
|
#children ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# 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 ⇒ Object
25
26
27
28
29
|
# 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 ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# 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
|