carrierwaveuploader / carrierwave-aws

AWS-SDK storage adapter for CarrierWave
MIT License
409 stars 107 forks source link

aws_attributes broken for ActiveSupport::OrderedOptions #180

Open kapcod opened 6 months ago

kapcod commented 6 months ago

Hello.

A common way to load CarrierWave config is from yml file using Rails.application.config_for method. This method returns object of class ActiveSupport::OrderedOptions which behaves similar to OpenStruct but responds to .call and returns nil for .call.

This line https://github.com/carrierwaveuploader/carrierwave-aws/blob/09c5baa6f7bf478f421467d5babefd4499ba72a5/lib/carrierwave/storage/aws_options.rb#L46 uses respond_to?(:call) to check if aws_attributes is proc which is broken in this case. I suggest checking it using is_a?(Proc) which will be more correct. On the other side it will break the "duck type" approach, so not sure what's the right solution here.