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

deep nested keys not pulled out correctly via method call approach #2

Closed
ak47 opened this issue Aug 26, 2009 · 4 comments
Closed

deep nested keys not pulled out correctly via method call approach #2

ak47 opened this issue Aug 26, 2009 · 4 comments

Comments

@ak47
Copy link

ak47 commented Aug 26, 2009

example yaml,

development:
bucket:
master:
pr: pcdlnv-mstr-dev
qa: pcdlnv-mstr-dev-qa
manifest:
pr: pcdlnv-mfst-dev
qa: pcdlnv-mfst-dev-qa
message:
pr: pcdlnv-msg-dev
qa: pcdlnv-msg-dev-qa

now in script/console

Settings.s3.bucket.message
=> {"pr"=>"pcdlnv-msg-dev", "qa"=>"pcdlnv-msg-dev-qa"}
Settings.s3.bucket.message.pr
=> "pcdlnv-mstr-dev"
Settings.s3.bucket.message['pr']
=> "pcdlnv-msg-dev"

when calling the value using the dotting method it gets the wrong value, but using Hash key is correct

@ghost
Copy link

ghost commented Aug 26, 2009

I wrote some tests, and I can't duplicate the issue. Want to write in your own tests and see if you can do it? Check this out:

http://github.com/binarylogic/settingslogic/commit/e9271139c5a0d7f93b7406a98c8d8019a374263d

@ak47
Copy link
Author

ak47 commented Aug 26, 2009

the ambiguity is when two child keys have the same value

I forked and made a test, http://github.com/ak47/settingslogic/tree/master

here's what I get

andy@pdd-andy-mbp (master)->spec spec/settingslogic_spec.rb
.....F..

'Settingslogic should access other extra deep nested settings' FAILED
expected: 5,
got: 2 (using ==)
./spec/settingslogic_spec.rb:25:

Finished in 0.044861 seconds

8 examples, 1 failure

it sets the child key name as a method, the one that gets set first has that method name to return it's value

example from above yml,

Settings.s3.bucket.master
/Users/andy/gits/tonopah/vendor/gems/settingslogic-2.0.2/lib/settingslogic.rb:63
self.class.send(:define_method, name) { value }
(rdb:1) c
=> {"pr"=>"pcdlnv-mstr-dev", "qa"=>"pcdlnv-mstr-dev-qa"}
Settings.s3.bucket.master.qa
=> "pcdlnv-msg-dev-qa"
Settings.s3.bucket.qa
=> "pcdlnv-msg-dev-qa"
Settings.s3.qa
=> "pcdlnv-msg-dev-qa"
Settings.qa
=> "pcdlnv-msg-dev-qa"

it doesn't matter what precedes the 'qa' call

@aaronchi
Copy link

I was having the same issue. Can't use the new version

@ghost
Copy link

ghost commented Sep 2, 2009

I pulled in some changes to fix this. Thanks.

mkonikowski pushed a commit to wearedalt/settingslogic that referenced this issue Oct 18, 2011
when parsing multiple yml files. use merge instead of replace.
This issue was closed.
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

2 participants