Class: OpenGraphReader::Object::Registry Private

Inherits:
Object
  • Object
show all
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.

API:

  • private

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

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.

API:

  • private



51
52
53
54
# File 'lib/open_graph_reader/object/registry.rb', line 51

def initialize
  @namespaces = {}
  @verticals = Set.new
end

Instance Attribute Details

#verticalsObject (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.

See Also:

API:

  • private



49
50
51
# File 'lib/open_graph_reader/object/registry.rb', line 49

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

Parameters:

  • The namespace in colon separated form, for example og:image.

Returns:

  • The matching class.

Raises:

  • If the given namespace wasn’t registered.

API:

  • private



41
# File 'lib/open_graph_reader/object/registry.rb', line 41

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.

Parameters:

  • The namespace in colon separated form, for example og:image.

  • The class to register. It should include OpenGraphReader::Object.

API:

  • private



41
# File 'lib/open_graph_reader/object/registry.rb', line 41

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.

Parameters:

  • The namespace in colon separated form, for example og:image.

Returns:

API:

  • private



41
# File 'lib/open_graph_reader/object/registry.rb', line 41

def_delegators :instance, :register, :registered?, :[], :verticals

.verticalsSet<String>

All known verticals

Returns:



41
# File 'lib/open_graph_reader/object/registry.rb', line 41

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.

Raises:

See Also:

API:

  • private



57
58
59
60
# File 'lib/open_graph_reader/object/registry.rb', line 57

def [] namespace
  raise UnknownNamespaceError, "#{namespace} is not a registered namespace" unless registered? namespace
  @namespaces[namespace]
end