Exception: Rackful::HTTP201Created

Inherits:
HTTPStatus
  • Object
show all
Defined in:
gems/rackful-0.1.1/lib/rackful_http_status.rb,
gems/rackful-0.1.1.orig/lib/rackful_http_status.rb

Overview

Since:

Instance Attribute Summary

Attributes inherited from HTTPStatus

#headers, #status, #to_rackful

Attributes included from Resource

#get_etag, #get_last_modified, #path

Instance Method Summary (collapse)

Methods included from Resource

#default_headers, #destroy, #do_METHOD, #empty?, #http_DELETE, #http_GET, #http_HEAD, #http_OPTIONS, #http_PUT, #http_method, #http_methods, included, #requested?, #serializer, #title, #to_rackful, #to_struct

Constructor Details

- (HTTP201Created) initialize(locations)

A new instance of HTTP201Created

Since:

  • 0.1.0



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'gems/rackful-0.1.1/lib/rackful_http_status.rb', line 107

def initialize locations
  locations = [ locations ] unless locations.kind_of? Array
  locations = locations.collect { |l| l.to_path }
  rf = Request.current.resource_factory
  if locations.size > 1
    locations = locations.collect {
      |l|
      resource = rf[l]
      { :location => l }.merge( resource.default_headers )
      rf.uncache l if rf.respond_to? :uncache
    }
    super(
      201, 'New resources were created:', :locations => locations
    )
  else
    location = locations[0]
    resource = rf[location]
    super(
      201, 'A new resource was created:', {
        :location => location,
        'Location' => location
      }.merge( resource.default_headers )
    )
  end
end