Skip to content

Hashie warning "You are setting a key that conflicts with a built-in method" #1643

Open
@aoyama-val

Description

@aoyama-val

Hashie 3.5.5
Grape 0.19.2

To reproduce:

require "grape"

class MyAPI < Grape::API
  params do
    requires :update, type: Boolean
  end
  get "hoge" do
    "update = #{params[:update]}"
  end
end

run MyAPI

Log:

W, [2017-06-06T14:18:35.531821 #46633]  WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#update defined at /Users/val00362/tmp/grapetest/vendor/bundle/ruby/2.3.0/gems/hashie-3.5.5/lib/hashie/mash.rb:209. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.

Hashie::Mash has built-in update method. It's conflicting with my parameter name. Similarly, you would see the warning when you used any of Hashie::Mash's 280+ methods. Is there any workaround about this? Or at least, some caveat to avoid these parameter names should be written in the README.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions