aws-s3 icon indicating copy to clipboard operation
aws-s3 copied to clipboard

Super Weird Class loading when I have a class ending in Bucket

Open jtushman opened this issue 13 years ago • 2 comments

Hi guys,

I had wrote a class: ConversionsByBucket, and weird things stared to happen.

After much hand wringing I tracked it down s3/extensions.rb overriding const_missing and hijacking modules/classes ending in 'Bucket'.

So:

  1. At the very least add a warning message, maybe: puts "Transforming #{sym.to_s} into a AWS::S3::Bucket, if using AWS/S3, ending modules/class with Bucket is reserved"

  2. Is the overriding of const_missing really necessary -- seem heavy handed.

Thanks,

Jonathan

jtushman avatar Nov 23 '11 19:11 jtushman

It was an after thought 6 years ago for marginal convenience on the assumption classes that ended in the word Bucket would be rare enough that the few libraries that used an AWS gem wouldn't be very likely to define non AWS Bucket classes.

It has turned out to be the single bigger source of frustration by a long shot in the relatively long life of the library. Meanwhile no one's written a blog post talking about how awesome inconveniences.

So I'm planning on making it deprecated in the next release with a big honking warning sign. And then the release after that I'll just get rid of it. For now it's probably safe for someone to just completely remove it. And when you upgrade you shouldn't have any problems.

"The best laid schemes of mice and men gang aft agley."

On Nov 23, 2011, at 11:36 AM, [email protected] wrote:

Hi guys,

I had wrote a class: ConversionsByBucket, and weird things stared to happen.

After much hand wringing I tracked it down s3/extensions.rb overriding const_missing and hijacking modules/classes ending in 'Bucket'.

So:

  1. At the very least add a warning message, maybe: puts "Transforming #{sym.to_s} into a AWS::S3::Bucket, if using AWS/S3, ending modules/class with Bucket is reserved"

  2. Is the overriding o const_missing really necessary -- seem heavy handed.

Thanks,

Jonathan


Reply to this email directly or view it on GitHub: https://github.com/marcel/aws-s3/issues/45

marcel avatar Nov 23 '11 20:11 marcel

First off dude -- thanks for your work on this library. Regarding backwards compatibility which I am sure is what you are worried about. I wonder if there is a good place to put a configuration setting to turn on or off this feature.

I.e.

# Some comments here explaining what this does 
S3::Config.enable_bucket_class_conversions = true;

Then for those of us who have issues with it can set it to false. I didn't see an easy place to put it, but just a thought. I am more than happy for you to just drop it.

Thanks again.

Also, anyone who uses this feature should chime in.

jtushman avatar Nov 23 '11 21:11 jtushman