Class: Flotte::Registry::Base

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/flotte/registry/base.rb

Direct Known Subclasses

Host, Role, Service

Instance Method Summary collapse

Constructor Details

#initialize(entities = []) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
# File 'lib/flotte/registry/base.rb', line 8

def initialize(entities = [])
  @entities_by_id = {}
  Array(entities).each do |entity|
    add(entity)
  end
end

Instance Method Details

#[](id) ⇒ Object



25
26
27
# File 'lib/flotte/registry/base.rb', line 25

def [](id)
  @entities_by_id[id]
end

#add(entity) ⇒ Object



15
16
17
18
19
# File 'lib/flotte/registry/base.rb', line 15

def add(entity)
  Array(entity).each do |entity|
    @entities_by_id[entity.id] = entity
  end
end

#allObject



21
22
23
# File 'lib/flotte/registry/base.rb', line 21

def all
  @entities_by_id.values
end