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

coerce :hooks (as a Hash) to Pry::Hooks instance in Pry.start().

This commit is contained in:
Robert Gleeson 2014-01-21 09:26:50 +01:00
parent 325016eb3a
commit fea2e22c0d
3 changed files with 3 additions and 2 deletions

View file

@ -18,6 +18,7 @@ class Pry
# @param [Hash] hash The hash to convert to `Pry::Hooks`. # @param [Hash] hash The hash to convert to `Pry::Hooks`.
# @return [Pry::Hooks] The resulting `Pry::Hooks` instance. # @return [Pry::Hooks] The resulting `Pry::Hooks` instance.
def self.from_hash(hash) def self.from_hash(hash)
return hash if hash.instance_of?(self)
instance = new instance = new
hash.each do |k, v| hash.each do |k, v|
instance.add_hook(k, nil, v) instance.add_hook(k, nil, v)

View file

@ -119,7 +119,7 @@ class Pry
end end
options[:target] = Pry.binding_for(target || toplevel_binding) options[:target] = Pry.binding_for(target || toplevel_binding)
options[:hooks] = Pry::Hooks.from_hash options.delete(:hooks) if options.key?(:hooks)
initial_session_setup initial_session_setup
# Unless we were given a backtrace, save the current one # Unless we were given a backtrace, save the current one

View file

@ -68,7 +68,7 @@ class Pry
@eval_string = "" @eval_string = ""
@backtrace = options[:backtrace] || caller @backtrace = options[:backtrace] || caller
@config = Pry::Config.new @config = Pry::Config.new
@config.merge!(options) config.merge!(options)
push_prompt(config.prompt) push_prompt(config.prompt)
@input_array = Pry::HistoryArray.new config.memory_size @input_array = Pry::HistoryArray.new config.memory_size
@output_array = Pry::HistoryArray.new config.memory_size @output_array = Pry::HistoryArray.new config.memory_size