Module: ServiceActor::Promptable::ClassMethods

Defined in:
lib/service_actor/promptable.rb

Overview

DSL for specifying the prompt

Instance Method Summary collapse

Instance Method Details

#inherited(child) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/service_actor/promptable.rb', line 36

def inherited(child)
  super

  child.prompt_with(
    prompt,
    unattended_options: ServiceActor::Promptable::UNATTENDED_DEFAULTS.merge(unattended_options).dup
  )
end

#promptObject



55
56
57
# File 'lib/service_actor/promptable.rb', line 55

def prompt
  @prompt
end

#prompt=(prompter) ⇒ Object



59
60
61
# File 'lib/service_actor/promptable.rb', line 59

def prompt=(prompter)
  @prompt = prompter
end

#prompt_with(prompter, unattended_options: {}) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/service_actor/promptable.rb', line 45

def prompt_with(prompter, unattended_options: {})
  unattended_options = ServiceActor::Promptable::UNATTENDED_DEFAULTS.merge(unattended_options)
  self.prompt = prompter
  self.unattended_options = unattended_options
  return unless unattended_options.key?(:prompt_toggle) && unattended_options[:prompt_toggle].is_a?(Symbol)

  # Create an Actor input :unattended (default) which must be either true or false
  input unattended_options[:prompt_toggle], in: [true, false], allow_nil: false, default: false
end

#unattended_optionsObject



63
64
65
# File 'lib/service_actor/promptable.rb', line 63

def unattended_options
  @unattended_options
end

#unattended_options=(unattended_options) ⇒ Object



67
68
69
# File 'lib/service_actor/promptable.rb', line 67

def unattended_options=(unattended_options)
  @unattended_options = unattended_options
end