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

one step closer to the behavior we want.

$ rake pry
[1] pry(main)> _pry_.config.requires
=> []
[2] pry(main)> _pry_.config.requires << 1
=> [1]
[3] pry(main)> Pry.config.requires = [1,2,3]
=> [1, 2, 3]
[4] pry(main)> _pry_.config.requires
=> [1, 2, 3]
[5] pry(main)> _pry_.config.requires = [42]
=> [42]
[6] pry(main)> Pry.config.requires = [5667]
=> [5667]
[7] pry(main)> _pry_.config.requires
=> [42]
[8] pry(main)> exit
This commit is contained in:
Robert Gleeson 2014-01-26 19:56:09 +01:00
parent c524e88f4c
commit bb79885787
3 changed files with 13 additions and 1 deletions

View file

@ -8,6 +8,8 @@ group :development do
gem 'rb-fsevent', :require => 'false'
end
gem 'binding.repl'
if RbConfig::CONFIG['ruby_install_name'] == 'rbx'
gem 'rubysl-singleton'
gem 'rubysl-prettyprint'

View file

@ -1,9 +1,10 @@
module Pry::Config::Behavior
ASSIGNMENT = "=".freeze
NODUP = [TrueClass, FalseClass, NilClass, Module, Proc, Numeric].freeze
NODUP = [TrueClass, FalseClass, NilClass, String, Module, Proc, Numeric].freeze
def initialize(default = Pry.config)
@default = default
@default._register(self) if @default
@lookup = {}
@read_lookup = {}
end
@ -20,6 +21,7 @@ module Pry::Config::Behavior
key = name.to_s
if key[-1] == ASSIGNMENT
short_key = key[0..-2]
@default._forget(short_key) if @default
self[short_key] = args[0]
elsif @lookup.has_key?(key)
self[key]

View file

@ -51,6 +51,14 @@ class Pry::Config::Default
configure_history
end
def _register(other)
@child = other
end
def _forget(key)
@child.instance_variable_get(:@read_lookup).delete(key.to_s)
end
default.each do |key, value|
define_method(key) do
if default[key].equal?(value)