Class: DatagroutConduit::GuidedSession

Inherits:
Object
  • Object
show all
Defined in:
lib/datagrout_conduit/client.rb

Overview

Wrapper around an active guided workflow session.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#stateObject (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

#completeObject

Check if the workflow is completed and return the result.

Raises:



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

#optionsObject



472
473
474
# File 'lib/datagrout_conduit/client.rb', line 472

def options
  @state.options
end

#resultObject



476
477
478
# File 'lib/datagrout_conduit/client.rb', line 476

def result
  @state.result
end

#session_idObject



464
465
466
# File 'lib/datagrout_conduit/client.rb', line 464

def session_id
  @state.session_id
end

#statusObject



468
469
470
# File 'lib/datagrout_conduit/client.rb', line 468

def status
  @state.status
end

#stepObject



480
481
482
# File 'lib/datagrout_conduit/client.rb', line 480

def step
  @state.step
end