Class: Kobako::Wire::Envelope::Request

Inherits:
Data
  • Object
show all
Defined in:
lib/kobako/wire/envelope.rb

Overview

Request (SPEC.md Wire Codec → Request)

4-element msgpack array: [target, method, args, kwargs]. target is either a String (“Group::Member”) or a Handle. SPEC pins kwargs map keys to ext 0x00 Symbol (→ Wire Codec → Ext Types); enforced at construction so the Value Object is the single source of truth.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target:, method:, args: [], kwargs: {}) ⇒ Request

Returns a new instance of Request.

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
# File 'lib/kobako/wire/envelope.rb', line 55

def initialize(target:, method:, args: [], kwargs: {})
  unless target.is_a?(String) || target.is_a?(Handle)
    raise ArgumentError, "Request target must be String or Handle, got #{target.class}"
  end
  raise ArgumentError, "Request method must be String" unless method.is_a?(String)
  raise ArgumentError, "Request args must be Array"    unless args.is_a?(Array)

  validate_kwargs!(kwargs)
  super(target: target, method_name: method, args: args, kwargs: kwargs)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



54
55
56
# File 'lib/kobako/wire/envelope.rb', line 54

def args
  @args
end

#kwargsObject (readonly)

Returns the value of attribute kwargs

Returns:

  • (Object)

    the current value of kwargs



54
55
56
# File 'lib/kobako/wire/envelope.rb', line 54

def kwargs
  @kwargs
end

#method_nameObject (readonly)

Returns the value of attribute method_name

Returns:

  • (Object)

    the current value of method_name



54
55
56
# File 'lib/kobako/wire/envelope.rb', line 54

def method_name
  @method_name
end

#targetObject (readonly)

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



54
55
56
# File 'lib/kobako/wire/envelope.rb', line 54

def target
  @target
end