class RakutenWebService::BaseGenre
Public Class Methods
[](id)
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 43 def self.[](id) new(repository[id.to_s] || id) end
[]=(id, genre)
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 47 def self.[]=(id, genre) repository[id.to_s] = genre end
genre_id_key()
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 31 def self.genre_id_key :"#{resource_name}_id" end
inherited(klass)
click to toggle source
Calls superclass method
RakutenWebService::Resource::inherited
# File lib/rakuten_web_service/genre.rb, line 7 def self.inherited(klass) super klass.parser do |response| current = response['current'] %w[children parents brothers].each do |type| elements = Array(response[type]).map { |e| klass.new(e) } current.merge!(type => elements) end genre = klass.new(current) [genre] end end
new(params)
click to toggle source
Calls superclass method
RakutenWebService::Resource::new
# File lib/rakuten_web_service/genre.rb, line 21 def self.new(params) case params when Integer, String return new(repository[params.to_s]) unless repository[params.to_s].nil? search(genre_id_key => params.to_s).first when Hash super end end
new(params)
click to toggle source
Calls superclass method
RakutenWebService::Resource::new
# File lib/rakuten_web_service/genre.rb, line 55 def initialize(params) super self.class[id.to_s] = @params.reject { |k, _| k == 'itemCount' } end
repository()
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 51 def self.repository @repository ||= {} end
root()
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 39 def self.root new(root_id) end
root_id(id = nil)
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 35 def self.root_id(id = nil) @root_id = id || @root_id end
Public Instance Methods
brothers()
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 64 def brothers @params['brothers'] ||= self.class.search(self.class.genre_id_key => id).first.brothers end
children()
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 60 def children @params['children'] ||= self.class.search(self.class.genre_id_key => id).first.children end
parents()
click to toggle source
# File lib/rakuten_web_service/genre.rb, line 68 def parents @params['parents'] ||= self.class.search(self.class.genre_id_key => id).first.parents end