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
@return [Handler, Class<Handler>] Returns the handler. This may
be a constructed handler object or a handler class.
@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.
@return [Set<String>]
@return [Integer]
@return [Symbol]
@return [Integer]
Public Class Methods
@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
@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
@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
# File lib/seahorse/client/handler_list_entry.rb, line 103 def compute_weight @weight = STEPS[@step] + @priority end
# 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
# 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
# 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