简体   繁体   中英

Ruby Resque , @queue instance varaible

I am a newbie and just started learning ruby. I find Resque amazing but am faced with a question when reading the documentation.

We define a @queue instance variable inside a job class without defining any attr_reader , so how can a worker find the value of this instance variable later?

Ruby does not provide true isolation of instance variables- it is more of a recommendation. So private instance variables of an object can actually be accessed by other objects through multiple means like instance_variable_get , instance_eval etc.

Resque uses instance_variable_get to extract the queue name from instance variable.

The relevant source is here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM