Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on Hashie::Mash (compatibility with hashie 3.3.0) #737

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/grape/http/request.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
module Grape
class Request < Rack::Request
class Params < ::Hash
include Hashie::Extensions::MergeInitializer
include Hashie::Extensions::IndifferentAccess
include Hashie::Extensions::MethodAccess

def convert_value(value)
super(value).tap do |converted_value|
if converted_value.is_a?(Hash)
value_self = (class << converted_value; self; end)
value_self.send :include, Hashie::Extensions::MethodAccess
end
end
end
end

def params
@params ||= begin
params = Hashie::Mash.new(super)
params = Params.new(super)
if env['rack.routing_args']
args = env['rack.routing_args'].dup
# preserve version from query string parameters
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/validations/coerce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _valid_single_type?(klass, val)
if klass == Virtus::Attribute::Boolean
val.is_a?(TrueClass) || val.is_a?(FalseClass)
elsif klass == Rack::Multipart::UploadedFile
val.is_a?(Hashie::Mash) && val.key?(:tempfile)
val.is_a?(Hash) && val.key?(:tempfile)
else
val.is_a?(klass)
end
Expand Down