Class: OembedProxy::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/oembed_proxy/handler.rb

Overview

Generic composing handler

Instance Method Summary collapse

Constructor Details

#initialize(*providers) ⇒ Handler

Returns a new instance of Handler.



6
7
8
# File 'lib/oembed_proxy/handler.rb', line 6

def initialize(*providers)
  @registered_providers = providers
end

Instance Method Details

#get_data(url, other_params = {}) ⇒ Object



18
19
20
21
# 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) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/oembed_proxy/handler.rb', line 14

def handles_url?(url)
  !provider_for_url(url).nil?
end

#register(provider) ⇒ Object



10
11
12
# File 'lib/oembed_proxy/handler.rb', line 10

def register(provider)
  @registered_providers << provider
end