Module: Asana::Resources::Registry Private
- Defined in:
- lib/asana/resource_includes/registry.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Global registry of Resource subclasses. It provides lookup from singular and plural names to the actual class objects.
Class Method Summary collapse
-
.lookup(singular_name) ⇒ Object
Looks up a resource class by its singular name.
-
.lookup_many(plural_name) ⇒ Object
Looks up a resource class by its plural name.
-
.register(resource_klass) ⇒ void
Registers a new resource class.
-
.resources ⇒ Object
private
A set of Resource classes.
Class Method Details
.lookup(singular_name) ⇒ Object
Looks up a resource class by its singular name.
34 35 36 37 38 |
# File 'lib/asana/resource_includes/registry.rb', line 34 def lookup(singular_name) resources.detect do |klass| klass.singular_name.to_s == singular_name.to_s end || Resource end |
.lookup_many(plural_name) ⇒ Object
Looks up a resource class by its plural name.
45 46 47 48 49 |
# File 'lib/asana/resource_includes/registry.rb', line 45 def lookup_many(plural_name) resources.detect do |klass| klass.plural_name.to_s == plural_name.to_s end || Resource end |
.register(resource_klass) ⇒ void
This method returns an undefined value.
Registers a new resource class.
25 26 27 |
# File 'lib/asana/resource_includes/registry.rb', line 25 def register(resource_klass) resources << resource_klass end |
.resources ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
this object is a mutable singleton, so it should not be accessed from multiple threads.
A set of Resource classes.
57 58 59 |
# File 'lib/asana/resource_includes/registry.rb', line 57 def resources @resources ||= Set.new end |