class OembedProxy::Handler
Generic composing handler
Public Class Methods
new(*providers)
click to toggle source
# File lib/oembed_proxy/handler.rb, line 6 def initialize(*providers) @registered_providers = providers end
Public Instance Methods
get_data(url, other_params = {})
click to toggle source
# File lib/oembed_proxy/handler.rb, line 18 def get_data(url, other_params = {}) provider = provider_for_url(url) return provider.get_data(url, other_params) unless provider.nil? end
handles_url?(url)
click to toggle source
# File lib/oembed_proxy/handler.rb, line 14 def handles_url?(url) !provider_for_url(url).nil? end
register(provider)
click to toggle source
# File lib/oembed_proxy/handler.rb, line 10 def register(provider) @registered_providers << provider end
Private Instance Methods
provider_for_url(url)
click to toggle source
# File lib/oembed_proxy/handler.rb, line 25 def provider_for_url(url) # TODO: Switch to #find @registered_providers.select { |p| p.handles_url? url }.first end