Module: Kinetic::DSL
- Included in:
- Base
- Defined in:
- lib/kinetic/dsl.rb
Instance Method Summary collapse
-
#get(key) ⇒ Object?
Gets a configuration value.
-
#get!(key) ⇒ Object
Gets a configuration value and returns an exception if the value is not present.
-
#logger ⇒ Logger
Returns the application logger instance.
-
#on_direct(key) {|message| ... } ⇒ Object
(also: #on)
Defines a direct queue subscription.
-
#set(key, value) ⇒ Boolean
Sets a configuration value.
Instance Method Details
#get(key) ⇒ Object?
Gets a configuration value
21 22 23 |
# File 'lib/kinetic/dsl.rb', line 21 def get(key) config[key.to_sym] end |
#get!(key) ⇒ Object
Gets a configuration value and returns an exception if the value is not present
32 33 34 35 |
# File 'lib/kinetic/dsl.rb', line 32 def get!(key) raise Kinetic::Errors::MissingConfigurationValue.new(key) unless (value = get(key)) value end |
#logger ⇒ Logger
Returns the application logger instance
56 57 58 |
# File 'lib/kinetic/dsl.rb', line 56 def logger @logger ||= reopen_logger end |
#on_direct(key) {|message| ... } ⇒ Object Also known as: on
Defines a direct queue subscription. Direct queues do not allow fuzzy matching so all messages sent to this queue must exactly match the key.
46 47 48 49 50 51 |
# File 'lib/kinetic/dsl.rb', line 46 def on_direct(key, &block) raise Kinetic::Errors::NoSubscriberBlock unless block_given? raise Kinetic::Errors::KeyMustBeString unless key.is_a? String logger.debug "Setting up '#{key}' on 'direct'" direct[key] = block end |
#set(key, value) ⇒ Boolean
Sets a configuration value
11 12 13 14 |
# File 'lib/kinetic/dsl.rb', line 11 def set(key, value) config[key.to_sym] = value true end |