Class: Tus::Expirator
- Inherits:
-
Object
- Object
- Tus::Expirator
- Defined in:
- lib/tus/expirator.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #expiration_due? ⇒ Boolean
- #expire_files! ⇒ Object
-
#initialize(storage, interval: 60) ⇒ Expirator
constructor
A new instance of Expirator.
Constructor Details
#initialize(storage, interval: 60) ⇒ Expirator
Returns a new instance of Expirator.
8 9 10 11 |
# File 'lib/tus/expirator.rb', line 8 def initialize(storage, interval: 60) @storage = storage @interval = interval end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
6 7 8 |
# File 'lib/tus/expirator.rb', line 6 def interval @interval end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
6 7 8 |
# File 'lib/tus/expirator.rb', line 6 def storage @storage end |
Instance Method Details
#expiration_due? ⇒ Boolean
26 27 28 |
# File 'lib/tus/expirator.rb', line 26 def expiration_due? Time.now - interval > last_expiration end |
#expire_files! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tus/expirator.rb', line 13 def expire_files! return unless expiration_due? update_last_expiration Thread.new do thread = Thread.current thread.abort_on_exception = false thread.report_on_exception = true if thread.respond_to?(:report_on_exception) # Ruby 2.4 _expire_files! end end |