Class: Webmachine::Decision::FSM
- Inherits:
-
Object
- Object
- Webmachine::Decision::FSM
- Includes:
- Flow, Helpers
- Defined in:
- lib/webmachine/decision/fsm.rb
Overview
Implements the finite-state machine described by the Webmachine sequence diagram.
Constant Summary
Constant Summary
Constants included from Helpers
Constants included from Flow
Webmachine::Decision::Flow::START, Webmachine::Decision::Flow::VERSION
Constants included from Conneg
Instance Attribute Summary (collapse)
-
- (Object) metadata
readonly
Returns the value of attribute metadata.
-
- (Object) request
readonly
Returns the value of attribute request.
-
- (Object) resource
readonly
Returns the value of attribute resource.
-
- (Object) response
readonly
Returns the value of attribute response.
Instance Method Summary (collapse)
-
- (FSM) initialize(resource, request, response)
constructor
A new instance of FSM.
- - (Object) run
Methods included from Helpers
#accept_helper, #encode_body, #encode_body_if_set, #ensure_quoted_header, #has_response_body?, #unquote_header, #variances
Methods included from Flow
#b10, #b11, #b12, #b13, #b3, #b4, #b5, #b6, #b7, #b8, #b9, #b9a, #b9b, #c3, #c4, #d4, #d5, #decision_test, #e5, #e6, #f6, #f7, #g11, #g7, #g8, #g9, #h10, #h11, #h12, #h7, #i12, #i13, #i4, #i7, #k13, #k5, #k7, #l13, #l14, #l15, #l17, #l5, #l7, #m16, #m20, #m20b, #m5, #m7, #n11, #n16, #n5, #o14, #o16, #o18, #o18b, #o20, #p11, #p3, #v3j18
Methods included from Conneg
#build_conneg_list, #choose_charset, #choose_encoding, #choose_media_type, #do_choose
Constructor Details
- (FSM) initialize(resource, request, response)
A new instance of FSM
10 11 12 13 |
# File 'lib/webmachine/decision/fsm.rb', line 10 def initialize(resource, request, response) @resource, @request, @response = resource, request, response @metadata = {} end |
Instance Attribute Details
- (Object) metadata (readonly)
Returns the value of attribute metadata
8 9 10 |
# File 'lib/webmachine/decision/fsm.rb', line 8 def @metadata end |
- (Object) request (readonly)
Returns the value of attribute request
8 9 10 |
# File 'lib/webmachine/decision/fsm.rb', line 8 def request @request end |
- (Object) resource (readonly)
Returns the value of attribute resource
8 9 10 |
# File 'lib/webmachine/decision/fsm.rb', line 8 def resource @resource end |
- (Object) response (readonly)
Returns the value of attribute response
8 9 10 |
# File 'lib/webmachine/decision/fsm.rb', line 8 def response @response end |
Instance Method Details
- (Object) run
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webmachine/decision/fsm.rb', line 15 def run begin state = Flow::START loop do response.trace << state result = send(state) case result when Fixnum # Response code respond(result) break when Symbol # Next state state = result else # You bwoke it raise InvalidResource.new(state, result) end end rescue => e # Handle all exceptions without crashing the server error_response(e, state) end end |