Class: DatagroutConduit::GuidedSession
- Inherits:
-
Object
- Object
- DatagroutConduit::GuidedSession
- Defined in:
- lib/datagrout_conduit/client.rb
Overview
Wrapper around an active guided workflow session.
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#choose(option_id) ⇒ Object
Make a choice and advance the workflow.
-
#complete ⇒ Object
Check if the workflow is completed and return the result.
-
#initialize(client, state) ⇒ GuidedSession
constructor
A new instance of GuidedSession.
- #options ⇒ Object
- #result ⇒ Object
- #session_id ⇒ Object
- #status ⇒ Object
- #step ⇒ Object
Constructor Details
#initialize(client, state) ⇒ GuidedSession
Returns a new instance of GuidedSession.
459 460 461 462 |
# File 'lib/datagrout_conduit/client.rb', line 459 def initialize(client, state) @client = client @state = state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
457 458 459 |
# File 'lib/datagrout_conduit/client.rb', line 457 def state @state end |
Instance Method Details
#choose(option_id) ⇒ Object
Make a choice and advance the workflow.
485 486 487 |
# File 'lib/datagrout_conduit/client.rb', line 485 def choose(option_id) @client.guide(session_id: session_id, choice: option_id.to_s) end |
#complete ⇒ Object
Check if the workflow is completed and return the result.
490 491 492 493 494 495 496 |
# File 'lib/datagrout_conduit/client.rb', line 490 def complete if status == "completed" && result return result end raise Error, "Workflow not complete (status: #{status}). Call choose() with an option." end |
#options ⇒ Object
472 473 474 |
# File 'lib/datagrout_conduit/client.rb', line 472 def @state. end |
#result ⇒ Object
476 477 478 |
# File 'lib/datagrout_conduit/client.rb', line 476 def result @state.result end |
#session_id ⇒ Object
464 465 466 |
# File 'lib/datagrout_conduit/client.rb', line 464 def session_id @state.session_id end |
#status ⇒ Object
468 469 470 |
# File 'lib/datagrout_conduit/client.rb', line 468 def status @state.status end |
#step ⇒ Object
480 481 482 |
# File 'lib/datagrout_conduit/client.rb', line 480 def step @state.step end |