lib/ppds/tumblr.rb in grumblr-2.3.4 vs lib/ppds/tumblr.rb in grumblr-2.3.5
- old
+ new
@@ -78,11 +78,11 @@
self.blogs = []
end
def query(action, data)
raise 'Cannot authenticate without credentials' unless data[:email] and data[:password]
- response = RestClient.post(API_URL + action, data)
+ response = RestClient.post(API_URL + action, data.stringify_keys!)
dump(response) if DEBUG
response.to_str
rescue RestClient::RequestFailed => e
raise 'Query failed: %s' % e.response.body
rescue RestClient::RequestTimeout
@@ -108,7 +108,18 @@
rescue Exception => e
puts e
false
end
+ end
+end
+
+class Hash
+ # taken from Ruby on Rails
+ # modified to replace undercores with dashes
+ def stringify_keys!
+ keys.each do |key|
+ self[key.to_s.gsub(/_/, '-')] = delete(key)
+ end
+ self
end
end