Guest User

Untitled

a guest
Jun 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. ## With a callback
  2. class Foo < ActiveRecord::Base
  3. attr_reader :thing, :thang
  4. def after_initialize
  5. @thing = nasty_computation
  6. @thang = other_nasty_computation
  7. end
  8. end
  9.  
  10. ## without a callback
  11. class Foo < ActiveRecord::Base
  12. def thing
  13. @thing ||= nasty_computation
  14. end
  15.  
  16. def thang
  17. @thang ||= other_nasty_computation
  18. end
  19. end
Add Comment
Please, Sign In to add comment