Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested settings overwrite defaults #21

Open
zetlan opened this issue Aug 16, 2011 · 12 comments
Open

Nested settings overwrite defaults #21

zetlan opened this issue Aug 16, 2011 · 12 comments

Comments

@zetlan
Copy link

zetlan commented Aug 16, 2011

Consider this settings.yaml file:

defaults: &defaults
  foo:
    bar: "baz"
    q: "bert"

development:
  <<: *defaults
  foo:
    bar: "xyzzy"

The intention is to do a multi-level merge of the defaults, so that in development you get Settings.foo = {"baz" => "xyzzy", q => "bert"} -- in other words, dev selectively overwrites the settings hash tree.

What you get instead is Settings.foo = {"baz" => "xyzzy"} -- the merge operates on the "foo" key, and doesn't check to see whether the value of Settings.foo may be a hash.

I'm getting around this now by using naming conventions (i.e., all the "foo" settings are foo_something) and putting all config options on the top level, but it would be much cleaner if nested settings were selectively merged.

Incidentally, this may be more or less a duplicate of issues #4 and #16, and I think there's at least one pull request to address this issue already.

@edrex-janrain
Copy link

👍

1 similar comment
@neersighted
Copy link

👍

@dlite922
Copy link

dlite922 commented Jan 7, 2013

real life issue with this bug:

defaults: 
  log: 
    file: /tmp/log.log
    level: 'WARN'

development: 
  log: 
    level: 'DEBUG'

first of all, that's not even valid YAML syntax, file and level need a " - " prefix to make a YAML list. , Even if you do this, when selecting 'development', the log file is not found. The whole log section gets overwritten, not the just the level key. NOT COOL! This bug alone makes settingslogic useless for me.

@TimPetricola
Copy link

👍

5 similar comments
@sprad
Copy link

sprad commented May 27, 2013

👍

@tkawachi
Copy link

tkawachi commented Jun 6, 2013

👍

@johnagan
Copy link

👍

@defance
Copy link

defance commented Oct 11, 2013

👍

@mtarnovan
Copy link

👍

@mtarnovan
Copy link

I forgot about an old fork of mine of settingslogic which does this: mtarnovan@a03bf1e

This fork also introduces a dependency on Hash#deep_merge from active_support

@cofiem
Copy link
Contributor

cofiem commented Jul 23, 2014

👍

1 similar comment
@ccurtisj
Copy link

👍

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

No branches or pull requests