Class: Nerve::Easy::Nerve

Inherits:
Object
  • Object
show all
Includes:
Fake::Hash, FixedInstanceId
Defined in:
lib/nerve/easy/nerve.rb

Instance Method Summary collapse

Methods included from FixedInstanceId

#instance_id, instance_id

Constructor Details

#initialize ⇒ Nerve

Returns a new instance of Nerve.



9
10
11
# File 'lib/nerve/easy/nerve.rb', line 9

def initialize
  @services = {}
end

Instance Method Details

#announce(service) ⇒ Object



12
13
14
# File 'lib/nerve/easy/nerve.rb', line 12

def announce service
  @services[service.name] = service
end

#to_nerve ⇒ Object



15
16
17
18
19
20
# File 'lib/nerve/easy/nerve.rb', line 15

def to_nerve
  {
    "instance_id" => instance_id,
    "services"    => @services.collect{|n,c| [n,c.to_nerve] }.to_h,
  }
end