What does set_if_nil.call do in ruby? -


i'm relatively new ruby , have legacy code support. in following line don't understand:

set_if_nil.call(:type, @config['type_1']) 

i assume it setting type variable to value of @config['type_1'], why call method well? also, there no type variable in class. method in passed object. parameter of object?

presumably set_if_nil defined proc. if is, call method executes proc, passing in :type , @config... parameters.

afaik, set_if_nil not defined part of ruby standard library, understand more details what's happening you'll have track down it's defined.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -