Module: RubyEventStore::ProcessManager
- Defined in:
- lib/ruby_event_store/process_manager.rb,
lib/ruby_event_store/process_manager/retry.rb,
lib/ruby_event_store/process_manager/version.rb
Defined Under Namespace
Modules: ProcessMethods, Retry, Subscriptions
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.with_state(&state_class_block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ruby_event_store/process_manager.rb', line 51 def self.with_state(&state_class_block) unless block_given? raise ArgumentError, "A block returning the state class is required." end Module.new do @state_definition_block = state_class_block define_method(:initial_state) do block = self.class.instance_variable_get(:@state_definition_block) raise "State definition block not found on #{self.class}" unless block state_class = block.call raise "State definition block did not return a Class" unless state_class.is_a?(Class) state_class.new end define_method(:state) do @state end def self.included(host_class) host_class.instance_variable_set(:@state_definition_block, @state_definition_block) host_class.include(ProcessMethods) host_class.include(Retry) host_class.extend(Subscriptions) end end end |