Skip to content

Commit 3743228

Browse files
author
r-obert
committed
add docs [ci skip]
1 parent 030c617 commit 3743228

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

lib/pry/config/memoization.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@ module Pry::Config::Memoization
22
MEMOIZED_METHODS = Hash.new {|h,k| h[k] = [] }
33

44
module ClassMethods
5+
#
6+
# Defines one or more methods who return a constant value after being
7+
# called once.
8+
#
9+
# @example
10+
# class Foo
11+
# include Pry::Config::Memoization
12+
# def_memoized({
13+
# foo: proc {1+10},
14+
# bar: proc{"aaa"<<"a"}
15+
# })
16+
# end
17+
#
18+
# @param [{String => Proc}] method_table
19+
#
20+
# @return [void]
21+
#
522
def def_memoized(method_table)
623
method_table.each do |method_name, method|
724
define_method(method_name) do
@@ -17,6 +34,10 @@ def self.included(mod)
1734
mod.extend(ClassMethods)
1835
end
1936

37+
#
38+
# @return [Array<Symbol>]
39+
# Returns the names of methods that have been defined by {ClassMethods#def_memoized}.
40+
#
2041
def memoized_methods
2142
MEMOIZED_METHODS[self.class]
2243
end

0 commit comments

Comments
 (0)