class GiantBomb::Resource
Public Class Methods
detail(id, conditions={})
click to toggle source
# File lib/giantbomb/resource.rb, line 22 def self.detail(id, conditions={}) search = GiantBomb::Search.new("/#{self.endpoints[:singular]}/#{self.endpoint_id + id.to_s}/") search.filter(conditions) self.new(search.fetch) end
endpoint_id()
click to toggle source
# File lib/giantbomb/resource.rb, line 18 def self.endpoint_id @@endpoint_id[self.name.downcase] end
endpoints()
click to toggle source
# File lib/giantbomb/resource.rb, line 14 def self.endpoints @@endpoints[self.name.downcase] end
has_resource(singular=nil, opts={})
click to toggle source
# File lib/giantbomb/resource.rb, line 6 def self.has_resource(singular=nil, opts={}) @@endpoints[self.name.downcase] = { singular: singular.nil? ? "#{self.name.downcase}" : singular, plural: opts[:plural].nil? ? "#{self.name.downcase}s" : opts[:plural] } @@endpoint_id[self.name.downcase] = opts[:id].nil? ? "" : "#{opts[:id]}-" end
list(conditions={})
click to toggle source
# File lib/giantbomb/resource.rb, line 28 def self.list(conditions={}) search = GiantBomb::Search.new("/#{self.endpoints[:plural]}") search.filter(conditions) search.fetch.collect do |result| self.new(result) end end
new(attributes={})
click to toggle source
# File lib/giantbomb/resource.rb, line 49 def initialize(attributes={}) attributes.each do |key, value| if self.respond_to?(key.to_sym) self.instance_variable_set("@#{key}", value) end end end
search(query)
click to toggle source
# File lib/giantbomb/resource.rb, line 36 def self.search(query) search = GiantBomb::Search.new search.resources("#{self.endpoints[:singular]}") search.query(query) search.fetch.collect do |result| self.new(result) end end
Also aliased as: find