Class: WADL::HTTPMethod

Inherits:
HasDocs show all
Defined in:
lib/wadl/http_method.rb

Constant Summary

Constant Summary

Constants inherited from CheapSchema

CheapSchema::ATTRIBUTES

Instance Attribute Summary

Attributes inherited from CheapSchema

#attributes, #href, #index_key, #parent

Instance Method Summary collapse

Methods inherited from HasDocs

#define_singleton

Methods inherited from CheapSchema

as_collection, as_member, contents_are_mixed_data, #dereference, #dereference_with_context, dereferencing_attr_accessor, dereferencing_instance_accessor, #each_attribute, #each_collection, #each_member, from_element, has_attributes, has_many, has_one, has_required, in_document, inherit, inherited, init, #initialize, #matches?, may_be_reference, may_be_reference?, #paths, #to_s

Constructor Details

This class inherits a constructor from WADL::CheapSchema

Instance Method Details

#call(resource, args = {}) ⇒ Object

Args:

:path - Values for path parameters
:query - Values for query parameters
:headers - Values for header parameters
:send_representation
:expect_representation


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/wadl/http_method.rb', line 50

def call(resource, args = {})
  unless parent.respond_to?(:uri)
    raise "You can't call a method that's not attached to a resource! (You may have dereferenced a method when you shouldn't have)"
  end

  resource ||= parent
  method = dereference

  uri = method.request ? method.request.uri(resource, args) : resource.uri(args)

  headers = uri.headers.dup
  headers['Accept'] = expect_representation.mediaType if args[:expect_representation]

  method.response.build(HTTPRequest.execute(
    uri, name, args[:send_representation], headers))
end

#responseObject



40
41
42
# File 'lib/wadl/http_method.rb', line 40

def response
  responses.first
end