Sha256: cf5daa3769e885273a7a520168aa778f9ebab8c12b39b35ff32f88fed8e7a3e4
Contents?: true
Size: 640 Bytes
Versions: 13
Compression:
Stored size: 640 Bytes
Contents
# frozen_string_literal: true module OembedProxy # Generic composing handler class Handler def initialize(*providers) @registered_providers = providers end def register(provider) @registered_providers << provider end def handles_url?(url) !provider_for_url(url).nil? end def get_data(url, other_params = {}) provider = provider_for_url(url) return provider.get_data(url, other_params) unless provider.nil? end private def provider_for_url(url) # TODO: Switch to #find @registered_providers.select { |p| p.handles_url? url }.first end end end
Version data entries
13 entries across 13 versions & 1 rubygems