Sha256: 839b88e1bfa0867adbdc4a4f801606e1e381947fc774a2695bc494986f5bae7c

Contents?: true

Size: 878 Bytes

Versions: 13

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

module BrowseEverything
  class Browser
    attr_reader :providers

    def initialize(opts = {})
      url_options = {}
      if opts.key?(:url_options)
        url_options = opts.delete(:url_options)
      else
        url_options = opts
        opts = BrowseEverything.config
      end

      @providers = ActiveSupport::HashWithIndifferentAccess.new
      opts.each_pair do |driver_key, config|
        begin
          driver = driver_key.to_s
          driver_klass = BrowseEverything::Driver.const_get((config[:driver] || driver).camelize.to_sym)
          @providers[driver_key] = driver_klass.new(config.merge(url_options: url_options))
        rescue NameError
          Rails.logger.warn "Unknown provider: #{driver}"
        end
      end
    end

    def first_provider
      @providers.to_hash.each_value.to_a.first
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
browse-everything-1.4.0 lib/browse_everything/browser.rb
browse-everything-1.3.0 lib/browse_everything/browser.rb
browse-everything-1.2.0 lib/browse_everything/browser.rb
browse-everything-1.1.2 lib/browse_everything/browser.rb
browse-everything-1.1.1 lib/browse_everything/browser.rb
browse-everything-1.1.0 lib/browse_everything/browser.rb
browse-everything-1.0.2 lib/browse_everything/browser.rb
browse-everything-1.0.1 lib/browse_everything/browser.rb
browse-everything-1.0.0 lib/browse_everything/browser.rb
browse-everything-1.0.0.rc2 lib/browse_everything/browser.rb
browse-everything-1.0.0.rc1 lib/browse_everything/browser.rb
browse-everything-0.16.1 lib/browse_everything/browser.rb
browse-everything-0.16.0 lib/browse_everything/browser.rb