summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2020-04-12 15:03:44 +0800
committerKyrylo Silin <silin@kyrylo.org>2020-04-12 15:10:57 +0800
commit5dd061c3406aa84e5cafd489a5c77e550b00d122 (patch)
tree9e526ce4e14379547b39633ac6369f62ad5b62b7 /lib
parentf0328a4dfa88a98d344086526d8e5a778b0452fd (diff)
downloadpry-5dd061c3406aa84e5cafd489a5c77e550b00d122.tar.gz
config: return `nil` on unknown option instead of raising
Returning `nil` on unknown option was default behaviour for Pry v0.12.x. In e5556a2be8627ec3fe594c738f10422d5a1f5d43 I changed that but I am not sure if it was intentional. This breaks plugins such as pry-theme (https://github.com/kyrylo/pry-theme/issues/59). Returning `nil` makes more sense, because we can write code like this: ``` Pry.config.foo ||= 123 ``` ...whereas as of now this is no longer possible and you would need to use `respond_to?` to achieve the same effect.
Diffstat (limited to 'lib')
-rw-r--r--lib/pry/config.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pry/config.rb b/lib/pry/config.rb
index 6c377a48..0e54bf69 100644
--- a/lib/pry/config.rb
+++ b/lib/pry/config.rb
@@ -239,17 +239,17 @@ class Pry
@custom_attrs[attr.to_s].call
end
- def method_missing(method_name, *args, &block)
+ # rubocop:disable Style/MethodMissingSuper
+ def method_missing(method_name, *args, &_block)
name = method_name.to_s
if name.end_with?('=')
self[name[0..-2]] = args.first
elsif @custom_attrs.key?(name)
self[name]
- else
- super
end
end
+ # rubocop:enable Style/MethodMissingSuper
def respond_to_missing?(method_name, include_all = false)
@custom_attrs.key?(method_name.to_s.tr('=', '')) || super