Class: Inbox
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Inbox
- Includes:
- Mongoid::Document, Mongoid::Timestamps, SimpleEnum::Mongoid
- Defined in:
- lib/templates/mongoid_inbox.rb,
lib/templates/activerecrod_inbox.rb
Instance Attribute Summary collapse
-
#allow_processing ⇒ Object
Returns the value of attribute allow_processing.
Instance Method Summary collapse
- #check_publishing ⇒ Object
- #check_threshold_reach ⇒ Object
- #increment_attempt ⇒ Object
- #process ⇒ Object
Instance Attribute Details
#allow_processing ⇒ Object
Returns the value of attribute allow_processing.
18 19 20 |
# File 'lib/templates/mongoid_inbox.rb', line 18 def allow_processing @allow_processing end |
Instance Method Details
#check_publishing ⇒ Object
47 48 49 |
# File 'lib/templates/mongoid_inbox.rb', line 47 def check_publishing self.allow_processing = false if processed? end |
#check_threshold_reach ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/templates/mongoid_inbox.rb', line 39 def check_threshold_reach return if attempts < ENV.fetch('INBOXABLE__MAX_ATTEMPTS', 3)&.to_i self.retry_at = Time.zone.now + ENV.fetch('INBOXABLE__RETRY_DELAY_IN_SECONDS', 5)&.to_i&.seconds self.status = :failed self.allow_processing = false end |
#increment_attempt ⇒ Object
30 31 32 33 |
# File 'lib/templates/mongoid_inbox.rb', line 30 def increment_attempt self.attempts = attempts + 1 self.last_attempted_at = Time.zone.now end |
#process ⇒ Object
35 36 37 |
# File 'lib/templates/mongoid_inbox.rb', line 35 def process processor_class_name.constantize.perform_async(id.to_s) end |