File: content_type_helpers.rb

package info (click to toggle)
ruby-grape 0.16.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,736 kB
  • ctags: 1,175
  • sloc: ruby: 17,103; makefile: 3
file content (11 lines) | stat: -rw-r--r-- 323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
module ContentTypeHelpers
  %w(put patch post delete).each do |method|
    define_method :"#{method}_with_json" do |uri, params = {}, env = {}, &block|
      params = params.to_json
      env['CONTENT_TYPE'] ||= 'application/json'
      send(method, uri, params, env, &block)
    end
  end
end

include(ContentTypeHelpers)