Class: BetterStorage::Configuration

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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
9
10
11
# File 'lib/better_storage/configuration.rb', line 6

def initialize
  @s3_endpoint = UNSET
  @namespace = UNSET
  @protect_production_files = UNSET
  @prefix_date_format = UNSET
end

Instance Method Details

#namespaceObject



23
24
25
# File 'lib/better_storage/configuration.rb', line 23

def namespace
  @namespace.equal?(UNSET) ? nil : @namespace
end

#namespace=(value) ⇒ Object



27
28
29
# File 'lib/better_storage/configuration.rb', line 27

def namespace=(value)
  @namespace = value&.gsub(/\/$/, "")
end

#prefix_date_formatObject



39
40
41
# File 'lib/better_storage/configuration.rb', line 39

def prefix_date_format
  @prefix_date_format.equal?(UNSET) ? "%Y%m" : @prefix_date_format
end

#prefix_date_format=(value) ⇒ Object



43
44
45
# File 'lib/better_storage/configuration.rb', line 43

def prefix_date_format=(value)
  @prefix_date_format = value
end

#protect_production_filesObject



31
32
33
# File 'lib/better_storage/configuration.rb', line 31

def protect_production_files
  @protect_production_files.equal?(UNSET) ? Rails.env.development? : @protect_production_files
end

#protect_production_files=(value) ⇒ Object



35
36
37
# File 'lib/better_storage/configuration.rb', line 35

def protect_production_files=(value)
  @protect_production_files = value
end

#s3_endpointObject



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

def s3_endpoint
  return @s3_endpoint unless @s3_endpoint.equal?(UNSET)
  service = ActiveStorage::Blob.service
  service.bucket.url if service.respond_to?(:bucket)
end

#s3_endpoint=(value) ⇒ Object



19
20
21
# File 'lib/better_storage/configuration.rb', line 19

def s3_endpoint=(value)
  @s3_endpoint = value
end