class Igdb::ApiResource
Attributes
path[RW]
representer[RW]
Public Class Methods
all(**kwargs)
click to toggle source
Alias for search
# File lib/igdb/models/api_resource.rb, line 43 def all(**kwargs) search(kwargs) end
count()
click to toggle source
# File lib/igdb/models/api_resource.rb, line 9 def count Igdb::Requester.get("#{path}/count")['count'] end
find(id, **kwargs)
click to toggle source
# File lib/igdb/models/api_resource.rb, line 17 def find(id, **kwargs) kwargs[:fields] = kwargs[:fields] || '*' if id.class == Array build_collection(Igdb::Requester.get("#{path}/#{id.join(',')}", kwargs), representer) else build_single_resource(Igdb::Requester.get("#{path}/#{id}", kwargs)[0], representer) end end
meta()
click to toggle source
# File lib/igdb/models/api_resource.rb, line 13 def meta Igdb::Requester.get("#{path}/meta") end
search(**kwargs)
click to toggle source
# File lib/igdb/models/api_resource.rb, line 34 def search(**kwargs) kwargs[:offset] = kwargs[:offset] || 0 kwargs[:limit] = kwargs[:limit] || 50 kwargs[:fields] = kwargs[:fields] || '*' build_collection(Igdb::Requester.get("#{path}/", kwargs), representer) end
slug(id, **kwargs)
click to toggle source
# File lib/igdb/models/api_resource.rb, line 27 def slug(id, **kwargs) kwargs[:fields] = kwargs[:fields] || '*' kwargs[:'filter[slug][eq]'] = id build_single_resource(Igdb::Requester.get("#{path}/", kwargs)[0], representer) end
Private Class Methods
build_collection(response, representer)
click to toggle source
# File lib/igdb/models/api_resource.rb, line 53 def build_collection(response, representer) representer.for_collection.new([]).from_hash(response) end
build_single_resource(response, representer)
click to toggle source
# File lib/igdb/models/api_resource.rb, line 49 def build_single_resource(response, representer) representer.new(new).from_hash(response) end