ruby-grape / ruby-grape/grape

Grape::DSL::Helpers::ClassMethods#helpers modifies helper module

Open
#1,335 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug? discuss!
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

Hi, Grape::DSL::Helpers::ClassMethods#helpers evaluates helper methods in context of a given helper module, that leads to problems if that helper module is used anywhere else.

Example

helpers MyHelperModule do
  def resource
    ...
  end
end

now if I include MyHelperModule anywhere else, I'll have resource method, that I don't want to include

Update:
https://github.com/ruby-grape/grape/blob/master/lib/grape/dsl/helpers.rb#L31

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/grape/dsl/helpers.rb around line 31 and inspect Grape::DSL::Helpers::ClassMethods#helpers. Reproduce the MyHelperModule example from the issue, then verify that using the helper through the DSL does not alter the module when it is included elsewhere.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.