Class: Transactor::Performance
- Inherits:
-
Object
- Object
- Transactor::Performance
- Defined in:
- lib/transactor/performance.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #perform(&block) ⇒ Object
- #performed? ⇒ Boolean
- #performing? ⇒ Boolean
- #rollback(&block) ⇒ Object
- #rollback_on_failure? ⇒ Boolean
- #rolled_back? ⇒ Boolean
- #started? ⇒ Boolean
- #state ⇒ Object
- #successful? ⇒ Boolean
- #to_s ⇒ Object
Instance Attribute Details
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
3 4 5 |
# File 'lib/transactor/performance.rb', line 3 def actor @actor end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/transactor/performance.rb', line 3 def result @result end |
Class Method Details
.perform(actor, *args, &block) ⇒ Object
5 6 7 |
# File 'lib/transactor/performance.rb', line 5 def self.perform(actor, *args, &block) new(actor, *args).perform(&block) end |
Instance Method Details
#failed? ⇒ Boolean
42 43 44 |
# File 'lib/transactor/performance.rb', line 42 def failed? started? && rolled_back? end |
#perform(&block) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/transactor/performance.rb', line 9 def perform(&block) @started = true @result = actor.perform(&block) @performed = true self end |
#performed? ⇒ Boolean
26 27 28 |
# File 'lib/transactor/performance.rb', line 26 def performed? !!@performed end |
#performing? ⇒ Boolean
34 35 36 |
# File 'lib/transactor/performance.rb', line 34 def performing? started? && !performed? end |
#rollback(&block) ⇒ Object
16 17 18 19 20 |
# File 'lib/transactor/performance.rb', line 16 def rollback(&block) actor.rollback(&block) @rolled_back = true self end |
#rollback_on_failure? ⇒ Boolean
46 47 48 |
# File 'lib/transactor/performance.rb', line 46 def rollback_on_failure? actor.rollback_on_failure? end |
#rolled_back? ⇒ Boolean
30 31 32 |
# File 'lib/transactor/performance.rb', line 30 def rolled_back? !!@rolled_back end |
#started? ⇒ Boolean
22 23 24 |
# File 'lib/transactor/performance.rb', line 22 def started? !!@started end |
#state ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/transactor/performance.rb', line 50 def state if failed? :failed elsif successful? :successful elsif performing? :performing elsif !started? :not_started else :unknown end end |
#successful? ⇒ Boolean
38 39 40 |
# File 'lib/transactor/performance.rb', line 38 def successful? performed? && !rolled_back? end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/transactor/performance.rb', line 64 def to_s "#{actor.to_s} #{state}" end |