Class: Warren::App::ConsumerAdd
- Inherits:
-
Object
- Object
- Warren::App::ConsumerAdd
- Defined in:
- lib/warren/app/consumer_add.rb
Overview
Handles the initial creation of the configuration object
Constant Summary collapse
- SUBSCRIBER_NAMESPACE =
Default namespace for new Subscribers
%w[Warren Subscriber].freeze
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Class Method Summary collapse
-
.invoke(shell, name, options) ⇒ ConsumerAdd
Add a consumer to the configuration file located at ‘options.path` Will prompt the user for input on the `shell` if information not provided upfront.
Instance Method Summary collapse
-
#initialize(shell, name, options) ⇒ ConsumerAdd
constructor
Create a consumer configuration object.
-
#invoke ⇒ Void
Create a new configuration yaml file at ‘@path` using sensible defaults and the provided exchange.
Constructor Details
#initialize(shell, name, options) ⇒ ConsumerAdd
Create a consumer configuration object. Use #invoke to gather information and generate the config
45 46 47 48 49 50 51 52 53 |
# File 'lib/warren/app/consumer_add.rb', line 45 def initialize(shell, name, ) @shell = shell @name = name @desc = [:desc] @queue = [:queue] @delay = [:delay] @config = Warren::Config::Consumers.new([:path]) @bindings = Warren::App::ExchangeConfig.parse(shell, [:bindings]) end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
13 14 15 |
# File 'lib/warren/app/consumer_add.rb', line 13 def desc @desc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/warren/app/consumer_add.rb', line 13 def name @name end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
13 14 15 |
# File 'lib/warren/app/consumer_add.rb', line 13 def queue @queue end |
Class Method Details
.invoke(shell, name, options) ⇒ ConsumerAdd
Add a consumer to the configuration file located at ‘options.path` Will prompt the user for input on the `shell` if information not provided upfront
30 31 32 |
# File 'lib/warren/app/consumer_add.rb', line 30 def self.invoke(shell, name, ) new(shell, name, ).invoke end |
Instance Method Details
#invoke ⇒ Void
Create a new configuration yaml file at ‘@path` using sensible defaults and the provided exchange. If exchange is nil, prompts the user
61 62 63 64 65 66 67 |
# File 'lib/warren/app/consumer_add.rb', line 61 def invoke check_name if @name # Check name before we gather facts, as its better to know we # might have an issue early. gather_facts write_configuration write_subscriber end |