Skip to content

Expose with :if and lambda stopped working on Ruby 2.4.1 #269

Open
@pre

Description

@pre

I updated to Ruby 2.4.1 and grape-entity started complaining about using a lambda with :if.

This worked perfectly on Ruby 2.4.0, grape 0.19.2 and grape-entity 0.6.1:

expose :context_company_id, if: -> { company_context? }

It doesn't help if I reduce the problem, this is still broken:

expose :anything, if: -> { true }

Using Ruby 2.4.1 the following error message appears instead:
caught error of type ArgumentError in after callback inside Grape::Middleware::Formatter : wrong number of arguments (given 2, expected 0)

I tried to attach a debugger at entity.rb:477, but I don't know how to figure out options. If I try to inspect it, it'll throw the same error. If I print it, it's very long and I have no idea what to look for.

    def exec_with_object(options, &block)
      debugger
      instance_exec(object, options, &block)
    end
(byebug) pp options.inspect
*** ArgumentError Exception: wrong number of arguments (given 2, expected 0)

Any ideas?

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