Created
February 11, 2011 09:33
-
-
Save morgoth/822127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def respond_with(*resources, &block) | |
raise "In order to use respond_with, first you need to declare the formats your " << | |
"controller responds to in the class level" if self.class.mimes_for_respond_to.empty? | |
if response = retrieve_response_from_mimes(&block) | |
options = resources.size == 1 ? {} : resources.extract_options! | |
resources = resources.size == 1 ? Array.wrap(resources.first) : resources | |
options.merge!(:default_response => response) | |
(options.delete(:responder) || self.class.responder).call(self, resources, options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment