Class: RoadForest::TestSupport::FSM
- Inherits:
-
Webmachine::Decision::FSM
- Object
- Webmachine::Decision::FSM
- RoadForest::TestSupport::FSM
- Defined in:
- lib/roadforest/test-support/dispatcher-facade.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#handle_exceptions ⇒ Object
Um, actually *don’t* handle exceptions.
- #initialize_tracing ⇒ Object
- #run ⇒ Object
Class Method Details
.dump_trace ⇒ Object
36 37 38 |
# File 'lib/roadforest/test-support/dispatcher-facade.rb', line 36 def self.dump_trace puts trace_dump end |
.trace_dump ⇒ Object
40 41 42 43 44 |
# File 'lib/roadforest/test-support/dispatcher-facade.rb', line 40 def self.trace_dump Webmachine::Trace.traces.map do |trace| TraceFormatter.new(Webmachine::Trace.fetch(trace)) end.join("\n") end |
.trace_on ⇒ Object
29 30 31 32 33 34 |
# File 'lib/roadforest/test-support/dispatcher-facade.rb', line 29 def self.trace_on unless ancestors.include? Webmachine::Trace::FSM include Webmachine::Trace::FSM end Webmachine::Trace.trace_store = :memory end |
Instance Method Details
#handle_exceptions ⇒ Object
Um, actually *don’t* handle exceptions
47 48 49 50 51 |
# File 'lib/roadforest/test-support/dispatcher-facade.rb', line 47 def handle_exceptions yield.tap do |result| #p result #ok end end |
#initialize_tracing ⇒ Object
53 54 55 56 |
# File 'lib/roadforest/test-support/dispatcher-facade.rb', line 53 def initialize_tracing return if self.class.ancestors.include? Webmachine::Trace::FSM super end |
#run ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/roadforest/test-support/dispatcher-facade.rb', line 58 def run state = Webmachine::Decision::Flow::START trace_request(request) loop do trace_decision(state) result = handle_exceptions { send(state) } case result when Fixnum # Response code respond(result) break when Symbol # Next state state = result else # You bwoke it raise InvalidResource, t('fsm_broke', :state => state, :result => result.inspect) end end ensure trace_response(response) end |