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.
492 493 494 495 |
# File 'lib/datagrout_conduit/client.rb', line 492 def initialize(client, state) @client = client @state = state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
490 491 492 |
# File 'lib/datagrout_conduit/client.rb', line 490 def state @state end |
Instance Method Details
#choose(option_id) ⇒ Object
Make a choice and advance the workflow.
518 519 520 |
# File 'lib/datagrout_conduit/client.rb', line 518 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.
523 524 525 526 527 528 529 |
# File 'lib/datagrout_conduit/client.rb', line 523 def complete if status == "completed" && result return result end raise Error, "Workflow not complete (status: #{status}). Call choose() with an option." end |
#options ⇒ Object
505 506 507 |
# File 'lib/datagrout_conduit/client.rb', line 505 def @state. end |
#result ⇒ Object
509 510 511 |
# File 'lib/datagrout_conduit/client.rb', line 509 def result @state.result end |
#session_id ⇒ Object
497 498 499 |
# File 'lib/datagrout_conduit/client.rb', line 497 def session_id @state.session_id end |
#status ⇒ Object
501 502 503 |
# File 'lib/datagrout_conduit/client.rb', line 501 def status @state.status end |
#step ⇒ Object
513 514 515 |
# File 'lib/datagrout_conduit/client.rb', line 513 def step @state.step end |