Guest User

Untitled

a guest
Dec 1st, 2016
132
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