mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
b5538b8501
* Remove` Pry::Config::Default` * Remove `Pry::Config::Memoization` * Remove confusing use of `instance_eval` * Add `Pry::Config.defaults` Returns an instance of `Pry::Config`, initialized with Pry defaults. Replaces the previous role of `Pry::Config::Default`.
27 lines
636 B
Ruby
27 lines
636 B
Ruby
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
|
|
end
|