Skip to content

Allow for falsey values to be set in config - #133

Open
bschrag620 wants to merge 2 commits into
basecamp:masterfrom
bschrag620:allow-false-config-values
Open

Allow for falsey values to be set in config#133
bschrag620 wants to merge 2 commits into
basecamp:masterfrom
bschrag620:allow-false-config-values

Conversation

@bschrag620

@bschrag620 bschrag620 commented Feb 13, 2025

Copy link
Copy Markdown

When setting the config from an initializer a Rails.application.reloader.to_prepare block, falsey config values are not honored. The audits1984 config assignment is structured slightly differently, which has been done since the code was originally added.

By aligning how the config values are set in config#set_from to match how audits1984 does it, falsey values can now be properly assigned.

Fixes #134

@bschrag620
bschrag620 marked this pull request as ready for review February 13, 2025 18:15
@bschrag620

Copy link
Copy Markdown
Author

@jorgemanrubia Do you mind taking a look at this and the related issue?

Comment thread lib/console1984/config.rb
def set_from(properties)
properties.each do |key, value|
public_send("#{key}=", value) if value.present?
public_send("#{key}=", value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing this works, but in any case checking for a nil value might be safer if we were to add a nil value to the keys.

Suggested change
public_send("#{key}=", value)
public_send("#{key}=", value) unless value.nil?

There are plenty of other fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

falsey config values are not persisted

3 participants