class Uricp::UriStrategy

Constants

STRATEGIES

This is an ordered list from the most specific to the most general

Public Class Methods

choose_strategy(options) click to toggle source
# File lib/uricp/uri_strategy.rb, line 7
def self.choose_strategy(options)
  current = options.reject { |k, _v| k.is_a? Symbol }
  strategy_list = []
  while STRATEGIES.detect { |klass| @strategy = klass.new(current).appropriate? }
    debug "#{name}: Selected strategy #{@strategy.class.name}"
    strategy_list << @strategy
    current = @strategy.proposed_options
  end
  if incomplete_strategy?(strategy_list)
    raise Uricp::UnsupportedURLtype, "Unsupported transfer from #{options['from_uri']} to #{options['to_uri']}"
  end

  strategy_list
end
incomplete_strategy?(list) click to toggle source
# File lib/uricp/uri_strategy.rb, line 22
def self.incomplete_strategy?(list)
  list.empty?
end