mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
refactored/simplified initialize method in Pry
This commit is contained in:
parent
2108a058dc
commit
a3ef0c1d3f
1 changed files with 5 additions and 6 deletions
|
@ -3,10 +3,10 @@ require 'readline'
|
||||||
class Pry
|
class Pry
|
||||||
|
|
||||||
# The list of configuration options.
|
# The list of configuration options.
|
||||||
ConfigOptions = [:input, :output, :commands, :print,
|
CONFIG_OPTIONS = [:input, :output, :commands, :print,
|
||||||
:prompt, :hooks]
|
:prompt, :hooks]
|
||||||
|
|
||||||
attr_accessor *ConfigOptions
|
attr_accessor *CONFIG_OPTIONS
|
||||||
|
|
||||||
# Create a new `Pry` object.
|
# Create a new `Pry` object.
|
||||||
# @param [Hash] options The optional configuration parameters.
|
# @param [Hash] options The optional configuration parameters.
|
||||||
|
@ -21,12 +21,11 @@ class Pry
|
||||||
# component of the REPL. (see print.rb)
|
# component of the REPL. (see print.rb)
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
|
|
||||||
h = {}
|
default_options = {}
|
||||||
ConfigOptions.each { |v| h[v] = Pry.send(v) }
|
CONFIG_OPTIONS.each { |v| default_options[v] = Pry.send(v) }
|
||||||
default_options = h
|
|
||||||
default_options.merge!(options)
|
default_options.merge!(options)
|
||||||
|
|
||||||
ConfigOptions.each do |key|
|
CONFIG_OPTIONS.each do |key|
|
||||||
instance_variable_set("@#{key}", default_options[key])
|
instance_variable_set("@#{key}", default_options[key])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue