Class: Shokkenki::Consumer::Model::Request

Inherits:
Hash
  • Object
show all
Defined in:
lib/shokkenki/consumer/model/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
13
# File 'lib/shokkenki/consumer/model/request.rb', line 6

def initialize attributes
  raise "No request method has been specified." unless attributes.has_key?(:method)
  raise "The request method must be a symbol." unless attributes[:method].is_a?(Symbol)

  raise "No request path has been specified." unless attributes.has_key?(:path)
  raise "The request path must be a string." unless attributes[:path].is_a?(String)
  merge! attributes
end

Instance Method Details

#labelObject



15
16
17
18
19
# File 'lib/shokkenki/consumer/model/request.rb', line 15

def label
  query = " ? #{self[:query].to_json}" if self[:query]
  headers = " headers: #{self[:headers].to_json}" if self[:headers]
  "#{self[:method]} #{self[:path]}#{query}#{headers}"
end