Class: CarrierWave::Uploader::Base
- Inherits:
-
Object
- Object
- CarrierWave::Uploader::Base
- Defined in:
- lib/carrierwave-aws.rb
Constant Summary collapse
- ACCEPTED_ACL =
%w[ private public-read public-read-write authenticated-read bucket-owner-read bucket-owner-full-control ].freeze
- ConfigurationError =
Class.new(StandardError)
Class Method Summary collapse
- .aws_acl=(acl) ⇒ Object
- .aws_signer(value = nil) ⇒ Object
- .aws_signer=(signer) ⇒ Object
- .normalized_acl(acl) ⇒ Object
- .validated_signer(signer) ⇒ Object
Instance Method Summary collapse
Class Method Details
.aws_acl=(acl) ⇒ Object
38 39 40 |
# File 'lib/carrierwave-aws.rb', line 38 def self.aws_acl=(acl) @aws_acl = normalized_acl(acl) end |
.aws_signer(value = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/carrierwave-aws.rb', line 52 def self.aws_signer(value = nil) self.aws_signer = value if value if instance_variable_defined?('@aws_signer') @aws_signer elsif superclass.respond_to? :aws_signer superclass.aws_signer end end |
.aws_signer=(signer) ⇒ Object
62 63 64 |
# File 'lib/carrierwave-aws.rb', line 62 def self.aws_signer=(signer) @aws_signer = validated_signer(signer) end |
.normalized_acl(acl) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/carrierwave-aws.rb', line 42 def self.normalized_acl(acl) normalized = acl.to_s.downcase.sub('_', '-') unless ACCEPTED_ACL.include?(normalized) raise ConfigurationError, "Invalid ACL option: #{normalized}" end normalized end |
.validated_signer(signer) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/carrierwave-aws.rb', line 66 def self.validated_signer(signer) unless signer.nil? || signer.instance_of?(Proc) && signer.arity == 2 raise ConfigurationError, 'Invalid signer option. Signer proc has to respond to' \ '`.call(unsigned_url, options)`' end signer end |
Instance Method Details
#asset_host_public ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/carrierwave-aws.rb', line 88 def asset_host_public if instance_variable_defined?('@asset_host_public') @asset_host_public else self.class.asset_host_public end || false end |
#aws_acl=(acl) ⇒ Object
76 77 78 |
# File 'lib/carrierwave-aws.rb', line 76 def aws_acl=(acl) @aws_acl = self.class.normalized_acl(acl) end |
#aws_signer ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/carrierwave-aws.rb', line 80 def aws_signer if instance_variable_defined?('@aws_signer') @aws_signer else self.class.aws_signer end end |