Method: AMQP::Protocol::Class::Method#initialize

Defined in:
lib/amqp/protocol.rb

#initialize(*args) ⇒ Method

Returns a new instance of Method.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/amqp/protocol.rb', line 8

def initialize *args
  opts = args.pop if args.last.is_a? Hash
  opts ||= {}
  
  @debug = 1 # XXX hack, p(obj) == '' if no instance vars are set
  
  if args.size == 1 and args.first.is_a? Buffer
    buf = args.shift
  else
    buf = nil
  end

  self.class.arguments.each do |type, name|
    val = buf ? buf.read(type) :
                args.shift || opts[name] || opts[name.to_s]
    instance_variable_set("@#{name}", val)
  end
end