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

Pry#refresh method to update Pry instance settings from Pry class

This commit is contained in:
John Mair 2011-06-01 03:12:29 +12:00
parent b8e7107715
commit 1f6130cdbb

View file

@ -19,12 +19,21 @@ class Pry
# @param [Hash] options The optional configuration parameters.
# @option options [#readline] :input The object to use for input.
# @option options [#puts] :output The object to use for output.
# @option options [Pry::CommandBase] :commands The object to use for commands. (see commands.rb)
# @option options [Hash] :hooks The defined hook Procs (see hooks.rb)
# @option options [Array<Proc>] :default_prompt The array of Procs to use for the prompts. (see prompts.rb)
# @option options [Pry::CommandBase] :commands The object to use for commands.
# @option options [Hash] :hooks The defined hook Procs
# @option options [Array<Proc>] :prompt The array of Procs to use for the prompts.
# @option options [Proc] :print The Proc to use for the 'print'
# component of the REPL. (see print.rb)
def initialize(options={})
refresh(options)
@command_processor = CommandProcessor.new(self)
end
# Refresh the Pry instance settings from the Pry class.
# Allows options to be specified to override settings from Pry class.
# @param [Hash] options The options to override Pry class settings
# for this instance.
def refresh(options={})
defaults = {}
attributes = [
:input, :output, :commands, :print,
@ -36,11 +45,10 @@ class Pry
defaults[attribute] = Pry.send attribute
end
defaults.merge!(options).each_key do |key|
send "#{key}=", defaults[key]
defaults.merge!(options).each do |key, value|
send "#{key}=", value
end
@command_processor = CommandProcessor.new(self)
true
end
# The current prompt.