Class: Statefully::State::Finished

Inherits:
Statefully::State show all
Defined in:
lib/statefully/state.rb

Overview

Finished state is a state which is successful, but should not be processed any further. This could be useful for things like early returns.

Instance Attribute Summary

Attributes inherited from Statefully::State

#previous

Instance Method Summary collapse

Methods inherited from Statefully::State

create, #each, #failed?, #fetch, #history, #inspect, #key?, #keys, #none?, #resolve, #successful?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Statefully::State

Instance Method Details

#diffDiff::Finished

Return a Diff between current and previous Statefully::State

This method reeks of :reek:UtilityFunction - just implementing an API.

Examples:

Statefully::State.create(key: 'val').finish.diff
=> #<Statefully::Diff::Finished>

461
462
463
# File 'lib/statefully/state.rb', line 461

def diff
  Diff::Finished.instance
end

#finished?Boolean

Check if the current Statefully::State is finished

Examples:

state = Statefully::State.create
state.finished?
=> false

state.finish.finished?
=> true

476
477
478
# File 'lib/statefully/state.rb', line 476

def finished?
  true
end