do not dup Pry::Config::Lazy objects on read from default.

This commit is contained in:
robert 2018-11-18 01:31:33 +01:00
parent 1f60cc1ff5
commit 2e77969bbb
4 changed files with 29 additions and 25 deletions

View File

@ -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'

View File

@ -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

View File

@ -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=#<"}/

27
lib/pry/config/lazy.rb Normal file
View File

@ -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