do not dup Pry::Config::Lazy objects on read from default.
This commit is contained in:
parent
1f60cc1ff5
commit
2e77969bbb
|
@ -111,6 +111,7 @@ require 'pry/plugins'
|
|||
require 'pry/core_extensions'
|
||||
require 'pry/basic_object'
|
||||
require "pry/prompt"
|
||||
require 'pry/config/lazy'
|
||||
require 'pry/config/behavior'
|
||||
require 'pry/config/memoization'
|
||||
require 'pry/config/default'
|
||||
|
|
|
@ -2,30 +2,6 @@ class Pry
|
|||
# The Pry config.
|
||||
# @api public
|
||||
class Config < Pry::BasicObject
|
||||
# Wraps a block so it can have a name.
|
||||
#
|
||||
# @example
|
||||
# proc1 = proc {}
|
||||
# proc2 = Pry::Config::Lazy.new(&proc {})
|
||||
#
|
||||
# proc1.is_a?(Pry::Config::Lazy)
|
||||
# #=> false
|
||||
# proc2.is_a?(Pry::Config::Lazy)
|
||||
# #=> true
|
||||
#
|
||||
# @api private
|
||||
# @since v0.12.0
|
||||
class Lazy
|
||||
def initialize(&block)
|
||||
@block = block
|
||||
end
|
||||
|
||||
# @return [Object]
|
||||
def call
|
||||
@block.call
|
||||
end
|
||||
end
|
||||
|
||||
include Behavior
|
||||
|
||||
def self.shortcuts
|
||||
|
|
|
@ -6,7 +6,7 @@ class Pry
|
|||
|
||||
NODUP = [
|
||||
TrueClass, FalseClass, NilClass, Symbol, Numeric, Module, Proc,
|
||||
Pry::Prompt
|
||||
Pry::Prompt, Pry::Config::Lazy
|
||||
].freeze
|
||||
|
||||
INSPECT_REGEXP = /#{Regexp.escape "default=#<"}/
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
class Pry
|
||||
class Config < Pry::BasicObject
|
||||
# Wraps a block so it can have a name.
|
||||
#
|
||||
# @example
|
||||
# proc1 = proc {}
|
||||
# proc2 = Pry::Config::Lazy.new(&proc {})
|
||||
#
|
||||
# proc1.is_a?(Pry::Config::Lazy)
|
||||
# #=> false
|
||||
# proc2.is_a?(Pry::Config::Lazy)
|
||||
# #=> true
|
||||
#
|
||||
# @api private
|
||||
# @since v0.12.0
|
||||
class Lazy
|
||||
def initialize(&block)
|
||||
@block = block
|
||||
end
|
||||
|
||||
# @return [Object]
|
||||
def call
|
||||
@block.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue