From: Florian Gilcher Date: 2008-05-17T17:49:50+09:00 Subject: Re: Not quite getting it. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On May 17, 2008, at 7:48 AM, Roger Alsing wrote: >> class Test >> attr_accessor :order >> >> def order=(order) >> if order.kind_of?(Giraffe) >> raise Exception.new("We package nearly everything, but >> Giraffes????") >> end >> end >> end >> > > So is it common practise to do it like this? > Eg. does active records have this kind of stuff in the generated code > that comes out of "has_many" etc? > > Anyway, I think I do buy this. > Preventing the wrong types form beeing used is pretty much the same as > preventing the use of null in C#. > It simply become an extra step in parameter validation. > > And thanks everyone for the replies :-) Yes, ActiveRecord checks for the type of Associations. I would not call it "common practice" to rely on the type, but as ActiveRecord maps type Names to Tables, it is desireable to do that. Regards, Florian Gilcher -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkgunCkACgkQJA/zY0IIRZYn+ACePMafw/w2cezCc8gSzgdzWBgr uYQAn0RfLmvRqQoztSRSda0FkwHj1V6j =r4bb -----END PGP SIGNATURE-----