Sha256: f4f71e38b300253f3aef8c282d7aa83fba9f6aafc22eec1949c4e8ce3e391150

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

module BrowseEverything
  module Driver
    class Base
      include BrowseEverything::Engine.routes.url_helpers

      attr_reader :config, :name
      attr_accessor :token

      def initialize(config, _session_info = {})
        @config = config
        validate_config
      end

      def key
        self.class.name.split(/::/).last.underscore
      end

      def icon
        'unchecked'
      end

      def name
        @name ||= (@config[:name] || self.class.name.split(/::/).last.titleize)
      end

      def validate_config
      end

      def contents(_path)
        []
      end

      def details(_path)
        nil
      end

      def link_for(path)
        [path, { file_name: File.basename(path) }]
      end

      def authorized?
        false
      end

      # @return [Array{URI,Object}] 2 elements: the URI, and session data to store under "#{provider_name}_data"
      def auth_link
        []
      end

      def connect(_params, _data)
        nil
      end

      private

      def callback
        connector_response_url(callback_options)
      end

      # remove the script_name parameter from the url_options since that is causing issues
      #   with the route not containing the engine path in rails 4.2.0
      def callback_options
        config[:url_options].reject { |k, _v| k == :script_name }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
browse-everything-0.12.0 lib/browse_everything/driver/base.rb
browse-everything-0.11.1 lib/browse_everything/driver/base.rb
browse-everything-0.11.0 lib/browse_everything/driver/base.rb