-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Oct 3, 2005, at 11:53 AM, Jim Jeffers wrote:> I understand how predicate and destructive methods work but if I
> want to make my own is it purely just a naming convention? Could I
> technically make a method that was not a predicate method but name
> it as such? Not that I would.. just wondering.
Yes, these are just Ruby naming conventions.
ActiveRecord takes it one step further, automatically creating
attribute_name? predicates for your boolean columns.
> Also, I''m unsure as to how to make my own destructive method. Can
> anyone send me an example of a custom destructive method?
class Foo < ActiveRecord::Base
def toggle!
self.active = !self.active?
save!
end
end
Best,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)
iD8DBQFDQYUeAQHALep9HFYRAiuzAKDe16ELbYQYhFbc9mJ8vpR6TZS+KQCgl9/c
qGyaTx2YKPY93IFViFBIuoM=DOyH
-----END PGP SIGNATURE-----