Class: Seahorse::Client::HandlerListEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/seahorse/client/handler_list_entry.rb

Overview

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.

Constant Summary collapse

STEPS =
{
  initialize: 400,
  validate: 300,
  build: 200,
  sign: 100,
  send: 0,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ HandlerListEntry

Returns a new instance of HandlerListEntry.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :handler_class (required, Class<Handler>)
  • :inserted (required, Integer)

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

  • :step (Symbol) — default: :build
  • :priority (Integer) — default: 50
  • :operations (Set<String>)


26
27
28
29
30
31
32
33
34
35
# 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 = options[:operations]
  @operations = Set.new(options[:operations]).map(&:to_s) if @operations
  set_step(options[:step] || :build)
  set_priority(options[:priority] || 50)
  compute_weight
end

Instance Attribute Details

#handler_classHandler, Class<Handler> (readonly)

Returns the handler. This may be a constructed handler object or a handler class.

Returns:

  • (Handler, Class<Handler>)

    Returns the handler. This may be a constructed handler object or a handler class.



39
40
41
# File 'lib/seahorse/client/handler_list_entry.rb', line 39

def handler_class
  @handler_class
end

#insertedInteger (readonly)

Returns 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.

Returns:

  • (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.



45
46
47
# File 'lib/seahorse/client/handler_list_entry.rb', line 45

def inserted
  @inserted
end

#operationsSet<String> (readonly)

Returns:

  • (Set<String>)


54
55
56
# File 'lib/seahorse/client/handler_list_entry.rb', line 54

def operations
  @operations
end

#priorityInteger (readonly)

Returns:

  • (Integer)


51
52
53
# File 'lib/seahorse/client/handler_list_entry.rb', line 51

def priority
  @priority
end

#stepSymbol (readonly)

Returns:

  • (Symbol)


48
49
50
# File 'lib/seahorse/client/handler_list_entry.rb', line 48

def step
  @step
end

#weightInteger (readonly)

Returns:

  • (Integer)


57
58
59
# File 'lib/seahorse/client/handler_list_entry.rb', line 57

def weight
  @weight
end

Instance Method Details

#<=>(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
63
64
65
66
# File 'lib/seahorse/client/handler_list_entry.rb', line 60

def <=>(other)
  if weight == other.weight
    other.inserted <=> inserted
  else
    weight <=> other.weight
  end
end

#copy(options = {}) ⇒ HandlerListEntry

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :handler_class (required, Class<Handler>)
  • :inserted (required, Integer)

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

  • :step (Symbol) — default: :build
  • :priority (Integer) — default: 50
  • :operations (Set<String>)

Returns:



70
71
72
# File 'lib/seahorse/client/handler_list_entry.rb', line 70

def copy(options = {})
  HandlerListEntry.new(@options.merge(options))
end