1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/lib/pry/config/lazy.rb

28 lines
636 B
Ruby
Raw Normal View History

class Pry
class Config < Pry::BasicObject
# The primary purpose for instances of this class is to be used as a
# configuration value that is computed upon each access, see {Pry.lazy}
# for more examples.
#
# @example
# num = 19
# _pry_.config.foo = Pry::Config::Lazy.new(&proc { num += 1 })
# _pry_.config.foo # => 20
# _pry_.config.foo # => 21
# _pry_.config.foo # => 22
#
# @api private
# @since v0.12.0
class Lazy
def initialize(&block)
@block = block
end
# @return [Object]
def call
@block.call
end
end
end
2018-11-17 19:33:52 -05:00
end