class BrowseEverything::Driver::Base
Abstract class for provider classes
Attributes
Provide accessor and mutator methods for @token and @code
Provide accessor and mutator methods for @token and @code
Public Class Methods
Provide a default sorting lambda @return [Proc]
# File lib/browse_everything/driver/base.rb, line 18 def default_sorter lambda { |files| files.sort do |a, b| if b.container? a.container? ? a.name.downcase <=> b.name.downcase : 1 else a.container? ? -1 : a.name.downcase <=> b.name.downcase end end } end
Set the sorter lambda (or proc) for all subclasses (see Class.inherited) @param subclass [Class] the class inheriting from BrowseEverything::Driver::Base
# File lib/browse_everything/driver/base.rb, line 33 def inherited(subclass) subclass.sorter = sorter super end
Constructor @param config_values [Hash] configuration for the driver
# File lib/browse_everything/driver/base.rb, line 41 def initialize(config_values) @config = config_values @sorter = self.class.sorter || self.class.default_sorter validate_config end
Public Instance Methods
Abstract method
# File lib/browse_everything/driver/base.rb, line 93 def auth_link(*_args) [] end
Ensure that the configuration Hash has indifferent access @return [ActiveSupport::HashWithIndifferentAccess]
# File lib/browse_everything/driver/base.rb, line 49 def config @config = ActiveSupport::HashWithIndifferentAccess.new(@config) if @config.is_a? Hash @config end
Abstract method
# File lib/browse_everything/driver/base.rb, line 98 def connect(*_args) nil end
Abstract method
# File lib/browse_everything/driver/base.rb, line 76 def contents(*_args) [] end
Generate the icon markup for the driver @return [String]
# File lib/browse_everything/driver/base.rb, line 65 def icon 'unchecked' end
Generate the key for the driver @return [String]
# File lib/browse_everything/driver/base.rb, line 59 def key self.class.name.split(/::/).last.underscore end
Generate the link for a resource at a given path @param path [String] the path to the resource @return [Array<String, Hash>]
# File lib/browse_everything/driver/base.rb, line 83 def link_for(path) [path, { file_name: File.basename(path) }] end
Generate the name for the driver @return [String]
# File lib/browse_everything/driver/base.rb, line 71 def name @name ||= @config[:name] || self.class.name.split(/::/).last.titleize end
Abstract method
# File lib/browse_everything/driver/base.rb, line 55 def validate_config; end
Private Instance Methods
Generate the URL for the API callback @return [String]
# File lib/browse_everything/driver/base.rb, line 116 def callback connector_response_url(callback_options) end
Generate the options for the Rails URL generation for API callbacks 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
@return [Hash]
# File lib/browse_everything/driver/base.rb, line 108 def callback_options options = config.to_hash options.deep_symbolize_keys! options[:url_options].reject { |k, _v| k == :script_name } end