module StickyElephant::PayloadTypes

Constants

TYPES

Order matters

Public Instance Methods

handler() click to toggle source
# File lib/sticky_elephant/payload_types.rb, line 13
def handler
  TYPES_HANDLERS.fetch(type)
end
type() click to toggle source
# File lib/sticky_elephant/payload_types.rb, line 6
def type
  return @type if defined? @type
  _type = TYPES.find {|sym| send("is_#{sym}?") }
  raise RuntimeError.new("Unable to find type for #{self}") if _type.nil?
  @type = _type
end

Private Instance Methods

is_handshake?() click to toggle source
# File lib/sticky_elephant/payload_types.rb, line 31
def is_handshake?
  valid_length?
end
is_invalid?() click to toggle source
# File lib/sticky_elephant/payload_types.rb, line 35
def is_invalid?
  true
end
is_query?() click to toggle source
# File lib/sticky_elephant/payload_types.rb, line 23
def is_query?
  bytes.first == "Q".ord && valid_length?
end
is_quit?() click to toggle source
# File lib/sticky_elephant/payload_types.rb, line 27
def is_quit?
  bytes.first == "X".ord && valid_length?
end
is_ssl_request?() click to toggle source
# File lib/sticky_elephant/payload_types.rb, line 19
def is_ssl_request?
  bytes == [0, 0, 0, 8, 4, 210, 22, 47]
end