Class: PresignedUpload::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/presigned_upload/configuration.rb

Overview

Configuration class

Constant Summary collapse

AVAILABLE_STORAGES =
[:aws].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



13
14
15
16
# File 'lib/presigned_upload/configuration.rb', line 13

def initialize
  @storage = nil
  @storage_options = {}
end

Instance Attribute Details

#adapter_classObject (readonly)

Returns the value of attribute adapter_class.



11
12
13
# File 'lib/presigned_upload/configuration.rb', line 11

def adapter_class
  @adapter_class
end

#storageObject

Returns the value of attribute storage.



10
11
12
# File 'lib/presigned_upload/configuration.rb', line 10

def storage
  @storage
end

#storage_optionsObject

Returns the value of attribute storage_options.



10
11
12
# File 'lib/presigned_upload/configuration.rb', line 10

def storage_options
  @storage_options
end

Instance Method Details

#configure!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/presigned_upload/configuration.rb', line 18

def configure!
  unless AVAILABLE_STORAGES.include?(storage)
    raise InvalidStorage, "Invalid storage option. Allowed types are: #{AVAILABLE_STORAGES}"
  end

  raise InvalidStorageConfig, "Empty storage options configuration" if storage_options.empty?

  case storage
  when :aws
    load_aws
  end

  self
end