I’m trying to work out how you pass blocks into methods.
Basically I have a method, and instead of having the user write this:
def user_config
@config[:config_value] = "what they want"
end
I’d like them to be able to do this:
user_config do
:config_value => "what they want"
end
But I dont know how to work with a block in the method.
Blocks are invoked with yield, so this:
called like this
should work as you want it to. The block returns
You take the each key in the hash and asign its value in the @config hash.