Module: X::Objects::Lookups::Communities

Included in:
API
Defined in:
x-objects/lib/x/objects/lookups/communities.rb

Overview

Look up and search communities, mixed into a client through API

Internal to x-objects: X::Objects::API includes it, and its methods are public API of the client that includes API, but the module is only how they are grouped, and some of them need the methods of another, so include API rather than this module alone.

Instance Method Summary collapse

Instance Method Details

#find_community(id, **params) {|problem| ... } ⇒ Community?

Look up a community by identifier

Examples:

Look up a community

client.find_community(1234567890).name

Parameters:

  • id (String, Integer, Community) —

    the identifier

  • params (Hash) —

    query parameters merged over the default parameters

Yield Parameters:

  • problem (Problem) —

    each problem the API reported, such as a resource that was not found

Returns:

  • (Community, nil) —

    the community or nil if the community was not found



25
26
27
# File 'x-objects/lib/x/objects/lookups/communities.rb', line 25

def find_community(id, **params, &)
  Community.find(id, client: self, **params, &)
end

#find_community!(id, **params) ⇒ Community

Look up a community by identifier, which must exist

Examples:

Look up a community

client.find_community!(1234567890).name

Parameters:

  • id (String, Integer, Community) —

    the identifier

  • params (Hash) —

    query parameters merged over the default parameters

Returns:

Raises:



38
39
40
# File 'x-objects/lib/x/objects/lookups/communities.rb', line 38

def find_community!(id, **params)
  Community.find!(id, client: self, **params)
end

#search_communities(query, **params) ⇒ Cursor

Search communities

Examples:

Print the communities matching a query

client.search_communities("ruby").each { |community| puts community.name }

Parameters:

  • query (String) —

    the search query

  • params (Hash) —

    query parameters merged over the default parameters

Returns:

  • (Cursor) —

    a cursor over the matching communities



50
51
52
# File 'x-objects/lib/x/objects/lookups/communities.rb', line 50

def search_communities(query, **params)
  Community.search(query, client: self, **params)
end