RiotGamesCookbooks / rbenv-cookbook

Installs and configures rbenv
http://community.opscode.com/cookbooks/rbenv
Apache License 2.0
137 stars 109 forks source link

Use lazy evaluation for the derived attributes #119

Closed rastasheep closed 9 years ago

rastasheep commented 9 years ago

Use lazy evaluation for the derived attributes to delay the string interpolation until later. With this user can override only one attribute without need for overriding all other attributes that use main one.

For example (before PR):

node.default[:rbenv][:install_prefix] = "/usr/local"

by overriding install_prefix you would not override default[:rbenv][:root_path] because it's interpolated before attribute from wrapper cookbook existed.

More info about this problem you can find here (tnx to @coderanger).

reset commented 9 years ago

@rastasheep there is a bit more to it than just changing the string assigned to the attribute. You need to also assign a value to the variable to be replaced. Unless I'm missing something here I don't think this will work.

rastasheep commented 9 years ago

I'm not sure about assigning to variable, because node.default is some kind variable too, and also in linked example it's not used on that way. In other hand it seems that there's need to use %{} syntax on every place where you use base attribute.

Do you maybe have some suggestion how we can test this?

It would be great to fix this because i have spent a few hours on debugging what causes wrong installation path.

coderanger commented 9 years ago

This is indeed not remotely functional.