Class: OpenGraphReader::Object::Registry Private
- Inherits:
-
Object
- Object
- OpenGraphReader::Object::Registry
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/open_graph_reader/object/registry.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Global registry of namespaces and their representing classes. Also tracks which verticals are defined.
Instance Attribute Summary collapse
- #verticals ⇒ Object readonly private
Class Method Summary collapse
-
.[](namespace) ⇒ Class
private
Fetch the class associated with the given namespace.
-
.register(namespace, klass) ⇒ Object
private
Register a new namespace in the registry.
-
.registered?(namespace) ⇒ Bool
private
Check whether a namespace is registered.
-
.verticals ⇒ Set<String>
All known verticals.
Instance Method Summary collapse
- #[](namespace) ⇒ Object private
-
#initialize ⇒ Registry
constructor
private
A new instance of Registry.
Constructor Details
#initialize ⇒ Registry
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.
Returns a new instance of Registry.
52 53 54 55 |
# File 'lib/open_graph_reader/object/registry.rb', line 52 def initialize @namespaces = {} @verticals = Set.new end |
Instance Attribute Details
#verticals ⇒ Object (readonly)
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.
50 51 52 |
# File 'lib/open_graph_reader/object/registry.rb', line 50 def verticals @verticals end |
Class Method Details
.[](namespace) ⇒ Class
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.
Fetch the class associated with the given namespace
42 |
# File 'lib/open_graph_reader/object/registry.rb', line 42 def_delegators :instance, :register, :registered?, :[], :verticals |
.register(namespace, klass) ⇒ 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.
Register a new namespace in the registry.
42 |
# File 'lib/open_graph_reader/object/registry.rb', line 42 def_delegators :instance, :register, :registered?, :[], :verticals |
.registered?(namespace) ⇒ Bool
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.
Check whether a namespace is registered.
42 |
# File 'lib/open_graph_reader/object/registry.rb', line 42 def_delegators :instance, :register, :registered?, :[], :verticals |
.verticals ⇒ Set<String>
All known verticals
42 |
# File 'lib/open_graph_reader/object/registry.rb', line 42 def_delegators :instance, :register, :registered?, :[], :verticals |
Instance Method Details
#[](namespace) ⇒ 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.
58 59 60 61 |
# File 'lib/open_graph_reader/object/registry.rb', line 58 def [] namespace raise UnknownNamespaceError, "#{namespace} is not a registered namespace" unless registered? namespace @namespaces[namespace] end |