class Riffer::Config::Files
File-attachment-download policy for Riffer::Messages::FilePart URL sources
Attributes
Allow file attachments to be downloaded to send to providers.
The object used to fetch a URL source’s bytes
Maximum file size to download before failing.
Maximum number of files to include in an individual message.
Execution pattern for downloading files.
Maximum amount of time to spend downloading a file before failing.
Public Class Methods
Source
# File lib/riffer/config.rb, line 135 def initialize @allow_downloads = false @max_bytes = 3_500_000 @timeout = 60 @max_per_message = nil @runner = Riffer::Runner::Sequential.new @downloader = Riffer::Files::Downloader.new end
Public Instance Methods
Source
# File lib/riffer/config.rb, line 149 def allow_downloads=(value) @allow_downloads = Riffer::Helpers::Boolean.coerce(value, attribute: "allow_downloads") end
Sets the allow_downloads flag, coercing boolean-ish values so an env-var +“false”+ (truthy in Ruby) doesn’t silently enable downloads. Raises Riffer::ArgumentError on an unrecognized value.
Source
# File lib/riffer/config.rb, line 202 def downloader=(value) raise Riffer::ArgumentError, "downloader must respond to #call" unless value.respond_to?(:call) @downloader = value end
Sets the object used to download bytes from a URL. Raises Riffer::ArgumentError if value does not respond to call.
Source
# File lib/riffer/config.rb, line 157 def max_bytes=(value) raise Riffer::ArgumentError, "max_bytes must be a positive integer" unless value.is_a?(Integer) && value.positive? @max_bytes = value end
Sets max_bytes, provided value is a positive integer. Raises Riffer::ArgumentError if value is not an Integer or less than or equal to 0.
Source
# File lib/riffer/config.rb, line 177 def max_per_message=(value) if value.is_a?(Integer) && value.positive? @max_per_message = value elsif value.nil? @max_per_message = nil else raise Riffer::ArgumentError, "max_per_message must be a positive integer or nil" end end
Sets max_per_message, provided value is either nil or a positive integer. Raises Riffer::ArgumentError if value is not an Integer or nil, or is less than or equal to 0.
Source
# File lib/riffer/config.rb, line 191 def runner=(value) valid = value.is_a?(Riffer::Runner) raise Riffer::ArgumentError, "runner must be a Riffer::Runner instance" unless valid @runner = value end
Sets the runner used to process file downloads, provided value is a Riffer::Runner. Raises Riffer::ArgumentError if value is not a Riffer::Runner.
Source
# File lib/riffer/config.rb, line 167 def timeout=(value) raise Riffer::ArgumentError, "timeout must be a positive integer" unless value.is_a?(Integer) && value.positive? @timeout = value end
Sets timeout, provided value is a positive integer. Raises Riffer::ArgumentError if value is not an Integer or is less than or equal to 0.