class Seahorse::Client::HandlerListEntry

A container for an un-constructed handler. A handler entry has the handler class, and information about handler priority/order.

This class is an implementation detail of the {HandlerList} class. Do not rely on public interfaces of this class.

Constants

STEPS

Attributes

handler_class[R]

@return [Handler, Class<Handler>] Returns the handler. This may

be a constructed handler object or a handler class.
inserted[R]

@return [Integer] The insertion order/position. This is used to

determine sort order when two entries have the same priority.
Entries inserted later (with a higher inserted value) have a
lower priority.
operations[R]

@return [Set<String>]

priority[R]

@return [Integer]

step[R]

@return [Symbol]

weight[R]

@return [Integer]

Public Class Methods

new(options) click to toggle source

@option options [required, Class<Handler>] :handler_class @option options [required, Integer] :inserted The insertion

order/position. This is used to determine sort order when two
entries have the same priority.

@option options [Symbol] :step (:build) @option options [Integer] :priority (50) @option options [Set<String>] :operations

# File lib/seahorse/client/handler_list_entry.rb, line 26
def initialize(options)
  @options = options
  @handler_class = option(:handler_class, options)
  @inserted = option(:inserted, options)
  @operations = Set.new((options[:operations] || []).map(&:to_s))
  set_step(options[:step] || :build)
  set_priority(options[:priority] || 50)
  compute_weight
end

Public Instance Methods

<=>(other) click to toggle source

@api private

# File lib/seahorse/client/handler_list_entry.rb, line 59
def <=>(other)
  if weight == other.weight
    other.inserted <=> inserted
  else
    weight <=> other.weight
  end
end
copy(options = {}) click to toggle source

@option options (see initialize) @return [HandlerListEntry]

# File lib/seahorse/client/handler_list_entry.rb, line 69
def copy(options = {})
  HandlerListEntry.new(@options.merge(options))
end

Private Instance Methods

compute_weight() click to toggle source
# File lib/seahorse/client/handler_list_entry.rb, line 103
def compute_weight
  @weight = STEPS[@step] + @priority
end
option(name, options) click to toggle source
# File lib/seahorse/client/handler_list_entry.rb, line 75
def option(name, options)
  if options.key?(name)
    options[name]
  else
    msg = "invalid :priority `%s', must be between 0 and 99"
    raise ArgumentError, msg % priority.inspect
  end
end
set_priority(priority) click to toggle source
# File lib/seahorse/client/handler_list_entry.rb, line 94
def set_priority(priority)
  if (0..99).include?(priority)
    @priority = priority
  else
    msg = "invalid :priority `%s', must be between 0 and 99"
    raise ArgumentError, msg % priority.inspect
  end
end
set_step(step) click to toggle source
# File lib/seahorse/client/handler_list_entry.rb, line 84
def set_step(step)
  if STEPS.key?(step)
    @step = step
  else
    msg = "invalid :step `%s', must be one of :initialize, :validate, "
    msg << ":build, :sign or :send"
    raise ArgumentError, msg % step.inspect
  end
end