ruby / ruby/irb

Support helper method extension API

Open
#588 0 comments 0 reactions 1 assignee View on GitHub

@st0012 is already working on this.

Since Jul 2, 2023.

enhancement
Dominant language
Ruby
Stars
478
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
12

Description

In #513, I proposed extension API for commands, but it doesn't cover all the extension needs. For example, Rails defines controller and helpers methods (and these methods too) for its Rails console, which are meant to be used as methods and be chained with other method calls. So they should not be treated as commands.

However, helper methods do share some common needs with commands, like:

  • Feature discovery, e.g. can be listed in the result of show_cmds (or help in the future)
  • Proper registration API and documentation (instead of manually including a module)

So I think we should provide (perhaps similar) extension for helper methods to fulfill such needs.

Details

Using Rails' controller helper as example:

module IRB
  module Helper
    class Controller < Helper::Base
      category "Rails"
      description "Gets a new instance of a controller object."

      def execute
        @controller ||= ApplicationController.new
      end
    end
  end
end

IRB::ExtendedCommandBundle.add_helper(:controller, IRB::Helper::Controller)

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.