Class: SmartPrompt::WorkerContext
- Inherits:
-
Object
- Object
- SmartPrompt::WorkerContext
show all
- Defined in:
- lib/smart_prompt/worker.rb
Instance Method Summary
collapse
Constructor Details
#initialize(conversation, params, engine) ⇒ WorkerContext
Returns a new instance of WorkerContext.
30
31
32
33
34
|
# File 'lib/smart_prompt/worker.rb', line 30
def initialize(conversation, params, engine)
@conversation = conversation
@params = params
@engine = engine
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/smart_prompt/worker.rb', line 36
def method_missing(method, *args, &block)
if @conversation.respond_to?(method)
@conversation.send(method, *args, &block)
else
super
end
end
|
Instance Method Details
#call_worker(worker_name, params = {}) ⇒ Object
52
53
54
55
|
# File 'lib/smart_prompt/worker.rb', line 52
def call_worker(worker_name, params = {})
worker = Worker.new(worker_name, @engine)
worker.execute(params)
end
|
#params ⇒ Object
48
49
50
|
# File 'lib/smart_prompt/worker.rb', line 48
def params
@params
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
44
45
46
|
# File 'lib/smart_prompt/worker.rb', line 44
def respond_to_missing?(method, include_private = false)
@conversation.respond_to?(method) || super
end
|