Permalink
Browse files

Switch to duck-typing based on #to_json

  • Loading branch information...
1 parent 2d20278 commit 96fc44b105f4d070e40a1ceab0c6828108532c01 Nick Sieger committed Jun 13, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/klomp/client.rb
View
@@ -25,9 +25,9 @@ def initialize(uri, options={})
end
def send(*args, &block)
- if @options[:translate_json] && [Array, Hash].any? { |type| args[1].kind_of?(type) }
+ if @options[:translate_json] && args[1].respond_to?(:to_json)
args[1] = args[1].to_json
- args[2] = {} if args[2].nil?
+ args[2] ||= {}
args[2][:'content-type'] = 'application/json'
else
args[1] = args[1].to_s

0 comments on commit 96fc44b

Please sign in to comment.