Class: Promiscuous::Key
- Inherits:
-
Object
- Object
- Promiscuous::Key
- Defined in:
- lib/promiscuous/key.rb
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(role, nodes = []) ⇒ Key
constructor
A new instance of Key.
- #join(*nodes) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(role, nodes = []) ⇒ Key
Returns a new instance of Key.
2 3 4 5 |
# File 'lib/promiscuous/key.rb', line 2 def initialize(role, nodes=[]) @role = role @nodes = nodes end |
Instance Method Details
#as_json(options = {}) ⇒ Object
22 23 24 |
# File 'lib/promiscuous/key.rb', line 22 def as_json(={}) to_s end |
#join(*nodes) ⇒ Object
7 8 9 |
# File 'lib/promiscuous/key.rb', line 7 def join(*nodes) self.class.new(@role, @nodes + nodes) end |
#to_s ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/promiscuous/key.rb', line 11 def to_s path = [] case @role when :pub then path << 'publishers' when :sub then path << 'subscribers' end path << Promiscuous::Config.app path += @nodes.compact path.join(':') end |