Permalink
Browse files

Adding support for API URLs not ending in ".json" via RemoteModel.ext…

…ension
  • Loading branch information...
clayallsopp committed May 9, 2012
1 parent 8d8070f commit 18689958219ff6023bbf12469308c1fd976d438a
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/requests.rb
View
@@ -2,6 +2,11 @@ module RemoteModule
class RemoteModel
class << self
attr_accessor :root_url, :default_url_options
+ attr_writer :extension
+
+ def extension
+ @extension || (self == RemoteModel ? false : RemoteModel.extension) || ".json"
+ end
#################################
# URLs for the resource
@@ -53,7 +58,7 @@ def complete_url(fragment)
if fragment[0..3] == "http"
return fragment
end
- (self.root_url || RemoteModule::RemoteModel.root_url) + fragment + ".json"
+ (self.root_url || RemoteModule::RemoteModel.root_url) + fragment + self.extension
end
def http_call(method, url, call_options = {}, &block)

0 comments on commit 1868995

Please sign in to comment.