lib/runcible/base.rb in runcible-1.0.5 vs lib/runcible/base.rb in runcible-1.0.6

- old
+ new

@@ -80,11 +80,11 @@ client = RestClient::Resource.new(clone_config[:url], client_options) end args = [method] args << generate_payload(options) if [:post, :put].include?(method) - args << headers + args << headers response = get_response(client, path, *args) process_response(response) rescue => e @@ -110,20 +110,28 @@ end.flatten().join('&') path + "?#{query_string}" end def generate_payload(options) - if options[:payload] - if options[:payload][:optional] - if options[:payload][:required] - payload = options[:payload][:required].merge(options[:payload][:optional]) + if options[:payload].is_a?(String) + return options[:payload] + elsif options[:payload].is_a?(Hash) + format_payload_json(options[:payload]) + end + end + + def format_payload_json(payload_hash) + if payload_hash + if payload_hash[:optional] + if payload_hash[:required] + payload = payload_hash[:required].merge(payload_hash[:optional]) else - payload = options[:payload][:optional] + payload = payload_hash[:optional] end - elsif options[:payload][:delta] - payload = options[:payload] + elsif payload_hash[:delta] + payload = payload_hash else - payload = options[:payload][:required] + payload = payload_hash[:required] end else payload = {} end