Class: Browserctl::WorkflowContext
- Inherits:
-
Object
- Object
- Browserctl::WorkflowContext
show all
- Defined in:
- lib/browserctl/workflow.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of WorkflowContext.
16
17
18
19
|
# File 'lib/browserctl/workflow.rb', line 16
def initialize(params, client)
@params = params
@client = client
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
35
36
37
38
39
|
# File 'lib/browserctl/workflow.rb', line 35
def method_missing(name, *args)
return @params[name] if @params.key?(name)
super
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
14
15
16
|
# File 'lib/browserctl/workflow.rb', line 14
def client
@client
end
|
Instance Method Details
#assert(condition, msg = "assertion failed") ⇒ Object
69
70
71
|
# File 'lib/browserctl/workflow.rb', line 69
def assert(condition, msg = "assertion failed")
raise WorkflowError, msg unless condition
end
|
#close_page(page_name) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/browserctl/workflow.rb', line 56
def close_page(page_name)
res = @client.close_page(page_name.to_s)
raise WorkflowError, res[:error] if res[:error]
res
end
|
#fetch(key) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/browserctl/workflow.rb', line 28
def fetch(key)
res = @client.fetch(key.to_s)
raise WorkflowError, res[:error] if res[:error]
res[:value]
end
|
#invoke(workflow_name, **override_params) ⇒ Object
63
64
65
66
67
|
# File 'lib/browserctl/workflow.rb', line 63
def invoke(workflow_name, **override_params)
name = workflow_name.to_s
guard_circular!(name)
track_invoke(name) { run_nested(workflow_name, **override_params) }
end
|
#open_page(page_name, url: nil) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/browserctl/workflow.rb', line 49
def open_page(page_name, url: nil)
res = @client.open_page(page_name.to_s, url: url)
raise WorkflowError, res[:error] if res[:error]
res
end
|
#page(name) ⇒ Object
45
46
47
|
# File 'lib/browserctl/workflow.rb', line 45
def page(name)
PageProxy.new(name.to_s, @client)
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
41
42
43
|
# File 'lib/browserctl/workflow.rb', line 41
def respond_to_missing?(name, include_private = false)
@params.key?(name) || super
end
|
#store(key, value) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/browserctl/workflow.rb', line 21
def store(key, value)
res = @client.store(key.to_s, value)
raise WorkflowError, res[:error] if res[:error]
value
end
|