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.
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.
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.
43 44 45 |
# File 'lib/open_graph_reader/object/registry.rb', line 43 def initialize @namespaces = {} 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
36 |
# File 'lib/open_graph_reader/object/registry.rb', line 36 def_delegators :instance, :register, :registered?, :[] |
.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.
36 |
# File 'lib/open_graph_reader/object/registry.rb', line 36 def_delegators :instance, :register, :registered?, :[] |
.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.
36 |
# File 'lib/open_graph_reader/object/registry.rb', line 36 def_delegators :instance, :register, :registered?, :[] |
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.
48 49 50 51 |
# File 'lib/open_graph_reader/object/registry.rb', line 48 def [] namespace raise ArgumentError, "#{namespace} is not a registered namespace" unless registered? namespace @namespaces[namespace] end |