Module: X::Resources::Finders
- Included in:
- Community, DirectMessage, List, BatchFinders
- Defined in:
- x-resources/lib/x/resources/finders.rb
Overview
Class methods that look resources up one at a time, extended into each resource class the API can look up
A resource the API offers no lookup of, such as a poll or a place, does not extend it, and so answers none of its methods, rather than answer them only to raise. BatchFinders includes it for a resource the API can also look up many at a time.
Internal to x-resources: the methods it gives a resource class, such as X::Post.find, are public API, but the module is only how they are shared, and which classes extend or include it can change within 1.x.
Instance Method Summary collapse
-
#find(id, client:, **params) {|problem| ... } ⇒ Resource?
Look up a resource by identifier.
-
#find!(id, client:, **params) ⇒ Resource
Look up a resource by identifier, which must exist.
Instance Method Details
#find(id, client:, **params) {|problem| ... } ⇒ Resource?
Look up a resource by identifier
35 |
# File 'x-resources/lib/x/resources/finders.rb', line 35 def find(id, client:, **params, &) = locate("#{endpoint!}/#{Utils.id_of(id, self)}", client:, **params, &) |
#find!(id, client:, **params) ⇒ Resource
Look up a resource by identifier, which must exist
The error it raises names the identifier looked up, whether the identifier or a resource was given. Its cause is the X::NotFound of a lookup the API answered with a 404 that reports the resource as not found.
55 56 57 |
# File 'x-resources/lib/x/resources/finders.rb', line 55 def find!(id, client:, **params) locate!("#{endpoint!}/#{Utils.id_of(id, self)}", Utils.id_from(id, self), client:, **params) end |