Skip to content

Commit

Permalink
moving creted responder into a trait
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Oct 29, 2010
1 parent 5f4e972 commit e228113
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/restfulie/client/dsl.rb
Expand Up @@ -9,7 +9,7 @@ def initialize
request :setup_header
request :serialize_body
request :enhance_response
request :cache
# request :cache
request :follow_request
end

Expand Down
19 changes: 0 additions & 19 deletions lib/restfulie/server/action_controller/created_responder.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/restfulie/server/action_controller/trait.rb
Expand Up @@ -2,7 +2,6 @@ module Restfulie
module Server
module ActionController #:nodoc:
module Trait #:nodoc:
puts "loading trait..."
Dir["#{File.dirname(__FILE__)}/trait/*.rb"].each {|f| autoload File.basename(f)[0..-4].camelize.to_sym, f }
end
end
Expand Down
17 changes: 17 additions & 0 deletions lib/restfulie/server/action_controller/trait/created.rb
@@ -0,0 +1,17 @@
module Restfulie::Server::ActionController
module Trait

# Adds support to answering as a 201 when the resource has been just created
module Created

def to_format
if (options[:status] == 201) || (options[:status] == :created)
head :status => 201, :location => controller.url_for(resource)
else
super
end
end

end
end
end

0 comments on commit e228113

Please sign in to comment.