Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix UserFileDefaultOptions#fetch implementation (#2233)
The usage of `||` fetch is incorrect,
as presence of `false` is the correct value.

This change uses `default` value,
only if the value is nowhere else defined.
  • Loading branch information
ayufan committed Apr 25, 2020
1 parent b0b17f6 commit 883b861
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -38,6 +38,7 @@
* Fixed a few minor concurrency bugs in ThreadPool that may have affected non-GVL Rubies (#2220)
* Fix `out_of_band` hook never executed if the number of worker threads is > 1 (#2177)
* Fix ThreadPool#shutdown timeout accuracy (#2221)
* Fix `UserFileDefaultOptions#fetch` to properly use `default` (#2233)

* Refactor
* Remove unused loader argument from Plugin initializer (#2095)
Expand Down
10 changes: 6 additions & 4 deletions lib/puma/configuration.rb
Expand Up @@ -54,17 +54,19 @@ def initialize(user_options, default_options)
attr_reader :user_options, :file_options, :default_options

def [](key)
return user_options[key] if user_options.key?(key)
return file_options[key] if file_options.key?(key)
return default_options[key] if default_options.key?(key)
fetch(key)
end

def []=(key, value)
user_options[key] = value
end

def fetch(key, default_value = nil)
self[key] || default_value
return user_options[key] if user_options.key?(key)
return file_options[key] if file_options.key?(key)
return default_options[key] if default_options.key?(key)

default_value
end

def all_of(key)
Expand Down

0 comments on commit 883b861

Please sign in to comment.