Class: Natsy::Config::Options
- Inherits:
-
Object
- Object
- Natsy::Config::Options
- Defined in:
- lib/natsy/config.rb
Overview
A Natsy::Config::Options object is passed as a single argument to the block (if provided) for the Natsy::Config::set method. This class should probably NOT be instantiated directly; instead, set the relevant options using Natsy::Config.set(some_option: “…”, some_other_option: “…”). If you find yourself instantiating this class directly, there’s probably a better way to do what you’re trying to do.
Instance Attribute Summary collapse
-
#default_queue ⇒ Object
Set a default queue for subscriptions.
-
#logger ⇒ Object
Attach a logger to have
natsywrite out logs for messages received, responses sent, errors raised, lifecycle events, etc. -
#url ⇒ Object
Specify a NATS server URL (or multiple URLs).
-
#urls ⇒ Object
Specify a NATS server URL (or multiple URLs).
Instance Method Summary collapse
-
#to_h ⇒ Object
Returns ONLY the config options THAT HAVE BEEN SET as a
Hash.
Instance Attribute Details
#default_queue ⇒ Object
Set a default queue for subscriptions.
NOTE: The following two examples do exactly the same thing.
Leave the ::default_queue blank (or assign nil) to use no default queue.
NOTE: The following two examples do exactly the same thing.
109 110 111 |
# File 'lib/natsy/config.rb', line 109 def default_queue @default_queue end |
#logger ⇒ Object
Attach a logger to have natsy write out logs for messages received, responses sent, errors raised, lifecycle events, etc.
NOTE: The following two examples do exactly the same thing.
In a Rails application, you might do this instead:
76 77 78 |
# File 'lib/natsy/config.rb', line 76 def logger @logger end |
#url ⇒ Object
Specify a NATS server URL (or multiple URLs)
NOTE: The following two examples do exactly the same thing.
NOTE: The following two examples do exactly the same thing.
If left blank/omitted, natsy will fall back on the default URL, which is nats://localhost:4222.
43 44 45 |
# File 'lib/natsy/config.rb', line 43 def url @url end |
#urls ⇒ Object
Specify a NATS server URL (or multiple URLs)
NOTE: The following two examples do exactly the same thing.
NOTE: The following two examples do exactly the same thing.
If left blank/omitted, natsy will fall back on the default URL, which is nats://localhost:4222.
43 44 45 |
# File 'lib/natsy/config.rb', line 43 def urls @urls end |
Instance Method Details
#to_h ⇒ Object
Returns ONLY the config options THAT HAVE BEEN SET as a Hash. Will not have keys for properties that are unassigned, but will have keys for properties assigned nil.
120 121 122 123 124 125 126 127 |
# File 'lib/natsy/config.rb', line 120 def to_h hash = {} hash[:url] = url if defined?(@url) hash[:urls] = urls if defined?(@urls) hash[:logger] = logger if defined?(@logger) hash[:default_queue] = default_queue if defined?(@default_queue) hash end |