diff options
| author | Stan Lo <stan001212@gmail.com> | 2024-04-24 16:59:39 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-04-24 16:01:02 +0000 |
| commit | e5ca3d072fd1076133dc7c3a9a2e399bbfcee443 (patch) | |
| tree | e11f36f2d2ee30a65b3afcf650c051e4fd33cf92 /lib | |
| parent | afc7799c3271aab7792c178ab9aee15b87468341 (diff) | |
[ruby/irb] Memoize helper method instances with Singleton module
Some helpers, like Rails console's `app`, requires memoization of the
helper's ivars. To support it IRB needs to memoize helper method instances
as well.
https://github.com/ruby/irb/commit/169a9a2c30
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/irb/helper_method/base.rb | 4 | ||||
| -rw-r--r-- | lib/irb/workspace.rb | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/irb/helper_method/base.rb b/lib/irb/helper_method/base.rb index dc74b046da..a68001ed28 100644 --- a/lib/irb/helper_method/base.rb +++ b/lib/irb/helper_method/base.rb @@ -1,6 +1,10 @@ +require "singleton" + module IRB module HelperMethod class Base + include Singleton + class << self def description(description = nil) @description = description if description diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb index dd92d99014..d24d1cc38d 100644 --- a/lib/irb/workspace.rb +++ b/lib/irb/workspace.rb @@ -179,7 +179,7 @@ EOF def self.install_helper_methods HelperMethod.helper_methods.each do |name, helper_method_class| define_method name do |*args, **opts, &block| - helper_method_class.new.execute(*args, **opts, &block) + helper_method_class.instance.execute(*args, **opts, &block) end unless method_defined?(name) end end |
