Sha256: 85d362a67a2bb65728e78ea08489e7a07d991751d63b4fab53ec2eabb0c607a6

Contents?: true

Size: 554 Bytes

Versions: 3

Compression:

Stored size: 554 Bytes

Contents

module IntrospectiveGrape
  module SnakeParams
    def snake_params_before_validation
      before_validation do
        # We have to snake case the Rack params then re-assign @params to the
        # request.params, because of the I-think-very-goofy-and-inexplicable
        # way Grape interacts with both independently of each other
        (params.try(:with_snake_keys)||{}).each do |k,v|
          request.delete_param(k.camelize(:lower))
          request.update_param(k, v)
        end
        @params = request.params
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
introspective_grape-0.3.2 lib/introspective_grape/snake_params.rb
introspective_grape-0.3.1 lib/introspective_grape/snake_params.rb
introspective_grape-0.3.0 lib/introspective_grape/snake_params.rb