saasbook

composition and delegation for SRP

Oct 15th, 2012
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. class Customer < ActiveRecord::Base
  2.   def initialize
  3.     @address = Address.new(self)
  4.   end
  5. end
  6.  
  7. class Address
  8.   def initialize(customer)
  9.     @customer = customer
  10.     # ...other initialization
  11.   end
  12.   attr_reader :customer
  13.   delegate :zip, :zip=, :street, :street=, :to => :customer
  14. end
Advertisement
Add Comment
Please, Sign In to add comment