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:
parent
b8e7107715
commit
1f6130cdbb
1 changed files with 15 additions and 7 deletions
|
@ -19,12 +19,21 @@ class Pry
|
||||||
# @param [Hash] options The optional configuration parameters.
|
# @param [Hash] options The optional configuration parameters.
|
||||||
# @option options [#readline] :input The object to use for input.
|
# @option options [#readline] :input The object to use for input.
|
||||||
# @option options [#puts] :output The object to use for output.
|
# @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 [Pry::CommandBase] :commands The object to use for commands.
|
||||||
# @option options [Hash] :hooks The defined hook Procs (see hooks.rb)
|
# @option options [Hash] :hooks The defined hook Procs
|
||||||
# @option options [Array<Proc>] :default_prompt The array of Procs to use for the prompts. (see prompts.rb)
|
# @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'
|
# @option options [Proc] :print The Proc to use for the 'print'
|
||||||
# component of the REPL. (see print.rb)
|
# component of the REPL. (see print.rb)
|
||||||
def initialize(options={})
|
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 = {}
|
defaults = {}
|
||||||
attributes = [
|
attributes = [
|
||||||
:input, :output, :commands, :print,
|
:input, :output, :commands, :print,
|
||||||
|
@ -36,11 +45,10 @@ class Pry
|
||||||
defaults[attribute] = Pry.send attribute
|
defaults[attribute] = Pry.send attribute
|
||||||
end
|
end
|
||||||
|
|
||||||
defaults.merge!(options).each_key do |key|
|
defaults.merge!(options).each do |key, value|
|
||||||
send "#{key}=", defaults[key]
|
send "#{key}=", value
|
||||||
end
|
end
|
||||||
|
true
|
||||||
@command_processor = CommandProcessor.new(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# The current prompt.
|
# The current prompt.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue