From: "Jonathan Date: 2005-12-06T10:53:03+09:00 Subject: Re: injecting dynamic methods into a class transfire wrote: > Couple suggestions: > > def ImageBlob.inject_attrib_assign_methods > > to > > def self.inject_accessors > > Using 'self' is more robust. Also in Ruby attribute methods are > generally refered to as accessors. > I agree with the name change. However, the class isn't instantiable, so using self won't work. I will change this to a module though. (you can call methods of a module without mixing it in right?) > def ImageBlob.getBlob( file, max_image_size ) > begin > img = Image.from_blob( file.read ).first > if not img > raise > end > > to > > def self.get_blob( file, max_image_size ) > begin > img = Image.from_blob( file.read ).first > return nil if not img > > Don't use camelcase (unless you're passionate about it) and there's no > need to raise if the rescue clause is just going ot return nil anyway. Thanks for point that out. I overlooked getBlob. --Jonathan -- Posted via http://www.ruby-forum.com/.