Class: SourceMonitor::Configuration::ImagesSettings

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

Constant Summary collapse

DEFAULT_MAX_DOWNLOAD_SIZE =

10 MB

10 * 1024 * 1024
DEFAULT_DOWNLOAD_TIMEOUT =

seconds

30
DEFAULT_ALLOWED_CONTENT_TYPES =
%w[
  image/jpeg
  image/png
  image/gif
  image/webp
  image/svg+xml
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeImagesSettings

Returns a new instance of ImagesSettings.



21
22
23
# File 'lib/source_monitor/configuration/images_settings.rb', line 21

def initialize
  reset!
end

Instance Attribute Details

#allowed_content_typesObject

Returns the value of attribute allowed_content_types.



6
7
8
# File 'lib/source_monitor/configuration/images_settings.rb', line 6

def allowed_content_types
  @allowed_content_types
end

#download_timeoutObject

Returns the value of attribute download_timeout.



6
7
8
# File 'lib/source_monitor/configuration/images_settings.rb', line 6

def download_timeout
  @download_timeout
end

#download_to_active_storageObject

Returns the value of attribute download_to_active_storage.



6
7
8
# File 'lib/source_monitor/configuration/images_settings.rb', line 6

def download_to_active_storage
  @download_to_active_storage
end

#max_download_sizeObject

Returns the value of attribute max_download_size.



6
7
8
# File 'lib/source_monitor/configuration/images_settings.rb', line 6

def max_download_size
  @max_download_size
end

Instance Method Details

#download_enabled?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/source_monitor/configuration/images_settings.rb', line 32

def download_enabled?
  !!download_to_active_storage
end

#reset!Object



25
26
27
28
29
30
# File 'lib/source_monitor/configuration/images_settings.rb', line 25

def reset!
  @download_to_active_storage = false
  @max_download_size = DEFAULT_MAX_DOWNLOAD_SIZE
  @download_timeout = DEFAULT_DOWNLOAD_TIMEOUT
  @allowed_content_types = DEFAULT_ALLOWED_CONTENT_TYPES.dup
end