Class: Pageflow::OembedProviders
- Inherits:
-
Object
- Object
- Pageflow::OembedProviders
- Defined in:
- lib/pageflow/oembed_providers.rb
Overview
Registry for oEmbed providers that can be used to resolve URLs.
Instance Method Summary collapse
- #find_by_name!(name) ⇒ Object private
-
#initialize ⇒ OembedProviders
constructor
A new instance of OembedProviders.
- #names ⇒ Object private
-
#register(name, endpoint:, url_patterns:) ⇒ Object
Register an oEmbed provider.
Constructor Details
#initialize ⇒ OembedProviders
Returns a new instance of OembedProviders.
4 5 6 |
# File 'lib/pageflow/oembed_providers.rb', line 4 def initialize @providers = {} end |
Instance Method Details
#find_by_name!(name) ⇒ 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.
27 28 29 30 31 |
# File 'lib/pageflow/oembed_providers.rb', line 27 def find_by_name!(name) @providers.fetch(name.to_s) do raise(OembedProviderNotFoundError, "Unknown oEmbed provider '#{name}'") end end |
#names ⇒ 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.
34 35 36 |
# File 'lib/pageflow/oembed_providers.rb', line 34 def names @providers.keys end |
#register(name, endpoint:, url_patterns:) ⇒ Object
Register an oEmbed provider.
20 21 22 23 24 |
# File 'lib/pageflow/oembed_providers.rb', line 20 def register(name, endpoint:, url_patterns:) provider = OEmbed::Provider.new(endpoint) url_patterns.each { |pattern| provider << pattern } @providers[name.to_s] = provider end |