Class: Stockpile::LockedExcutionResult
- Inherits:
-
Object
- Object
- Stockpile::LockedExcutionResult
- Defined in:
- lib/stockpile/locked_execution_result.rb
Overview
Stockpile::LockedExcutionResult
Wrapper containing result of locked execution
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#lock_key ⇒ Object
readonly
Returns the value of attribute lock_key.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(db: :default, lock_key:, result:) ⇒ LockedExcutionResult
constructor
A new instance of LockedExcutionResult.
- #release_lock ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(db: :default, lock_key:, result:) ⇒ LockedExcutionResult
Returns a new instance of LockedExcutionResult.
24 25 26 27 28 |
# File 'lib/stockpile/locked_execution_result.rb', line 24 def initialize(db: :default, lock_key:, result:) @db = db @lock_key = lock_key @result = result end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
22 23 24 |
# File 'lib/stockpile/locked_execution_result.rb', line 22 def db @db end |
#lock_key ⇒ Object (readonly)
Returns the value of attribute lock_key.
22 23 24 |
# File 'lib/stockpile/locked_execution_result.rb', line 22 def lock_key @lock_key end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
22 23 24 |
# File 'lib/stockpile/locked_execution_result.rb', line 22 def result @result end |
Instance Method Details
#release_lock ⇒ Object
30 31 32 |
# File 'lib/stockpile/locked_execution_result.rb', line 30 def release_lock Stockpile.redis(db: db) { |r| r.expire(lock_key, 0) } end |
#success? ⇒ Boolean
34 35 36 |
# File 'lib/stockpile/locked_execution_result.rb', line 34 def success? !result.is_a?(Stockpile::FailedLockExecution) end |