SHARE
TWEET

Untitled

a guest Dec 1st, 2016 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Parent
  2.    class<<self; attr_accessor :sacred_var end
  3. end
  4.  
  5. class Child < Parent
  6.   def method_of_child
  7.     # I want to change @sacred_var here:
  8.     Parent.instance_eval { @sacred_var = 'new_value'}
  9.   end
  10. end
  11.  
  12. Parent.var) #=> 1
  13. Child.new.method_of_child
  14.  
  15. Parent.var #=> 'new_value'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top