Skip to content

Instantly share code, notes, and snippets.

@ehelms
Created September 7, 2013 15:17
Show Gist options
  • Save ehelms/6476483 to your computer and use it in GitHub Desktop.
Save ehelms/6476483 to your computer and use it in GitHub Desktop.
args << generate_payload(options) if [:post, :put].include?(method)
def generate_payload(options)
if options.has_key?(:body)
return options[:body]
elsif options.has_key?(:payload)
return format_payload(options[:payload])
end
end
def format_payload(payload)
if !payload.nil?
if payload[:optional]
if payload[:required]
payload = payload[:required].merge(payload[:optional])
else
payload = payload[:optional]
end
elsif options[:payload][:delta]
payload = payload
else
payload = payload[:required]
end
else
payload = {}
end
return payload.to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment