Module: ServiceActor::Promptable
- Defined in:
- lib/service_actor/promptable.rb,
lib/service_actor/promptable/version.rb,
lib/service_actor/promptable/unattended.rb
Overview
Adds the ‘prompt_with` DSL to actors. This allows you to set a prompt interface. It is suggested to use the `tty-prompt` gem, but any prompt tool should work. Then you are able to call `.prompt` and manipulate the prompt during a play.
class PromptableActor < Actor
prompt_with TTY::Prompt.new
def call
super
self.prompt = TTY::Prompt.new
end
end
Defined Under Namespace
Modules: ClassMethods, Version
Classes: Unattended
Constant Summary
collapse
- UNATTENDED_DEFAULTS =
{
prompt_toggle: :unattended,
answer_with: true
}.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
30
31
32
|
# File 'lib/service_actor/promptable.rb', line 30
def self.included(base)
base.extend(ClassMethods)
end
|
Instance Method Details
#prompt ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/service_actor/promptable.rb', line 72
def prompt
if self.class.unattended_options[:prompt_toggle] && send(self.class.unattended_options[:prompt_toggle])
Unattended.new(self.class.unattended_options[:answer_with])
else
self.class.prompt
end
end
|
#prompt=(prompter) ⇒ Object
80
81
82
|
# File 'lib/service_actor/promptable.rb', line 80
def prompt=(prompter)
self.class.prompt = prompter
end
|
#unattended_options ⇒ Object
84
85
86
|
# File 'lib/service_actor/promptable.rb', line 84
def unattended_options
self.class.unattended_options
end
|
#unattended_options=(unattended_options) ⇒ Object
88
89
90
|
# File 'lib/service_actor/promptable.rb', line 88
def unattended_options=(unattended_options)
self.class.unattended_options = unattended_options
end
|