Skip to content

Commit

Permalink
Merge pull request #151 from redis-rb/validate-db-argument
Browse files Browse the repository at this point in the history
Eagerly fail if db parameter isn't an Integer
  • Loading branch information
byroot authored Nov 13, 2023
2 parents 3a1b4f8 + 9007f5d commit ba8848b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Eagerly fail if `db:` isn't an Integer. #151.

# 0.18.0

- Expose more connection details such as `host`, `db`, etc on `RedisClient`.
Expand Down
7 changes: 6 additions & 1 deletion lib/redis_client/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def initialize(
)
@username = username
@password = password
@db = db || DEFAULT_DB
@db = begin
Integer(db || DEFAULT_DB)
rescue ArgumentError
raise ArgumentError, "db: must be an Integer, got: #{db.inspect}"
end

@id = id
@ssl = ssl || false

Expand Down

0 comments on commit ba8848b

Please sign in to comment.