mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
18c45d26c5
This will greatly ease Pry support on Ruby 3.0 (when it's out).
29 lines
618 B
Ruby
29 lines
618 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Pry
|
|
class Config
|
|
# LazyValue is a Proc (block) wrapper. It is meant to be used as a
|
|
# configuration value. Subsequent `#call` calls always evaluate the given
|
|
# block.
|
|
#
|
|
# @example
|
|
# num = 19
|
|
# value = Pry::Config::LazyValue.new { num += 1 }
|
|
# value.foo # => 20
|
|
# value.foo # => 21
|
|
# value.foo # => 22
|
|
#
|
|
# @api private
|
|
# @since ?.?.?
|
|
# @see Pry::Config::MemoizedValue
|
|
class LazyValue
|
|
def initialize(&block)
|
|
@block = block
|
|
end
|
|
|
|
def call
|
|
@block.call
|
|
end
|
|
end
|
|
end
|
|
end
|