Class: Mongo::Event::DescriptionChanged

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/event/description_changed.rb

Overview

This handles a change in description.

Since:

  • 2.0.6

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster) ⇒ DescriptionChanged

Initialize the new host added event handler.

Examples:

Create the new handler.

ServerAdded.new(cluster)

Parameters:

Since:

  • 2.0.0



35
36
37
# File 'lib/mongo/event/description_changed.rb', line 35

def initialize(cluster)
  @cluster = cluster
end

Instance Attribute Details

#clusterMongo::Cluster (readonly)

Returns cluster The event publisher.

Returns:

Since:

  • 2.0.6



25
26
27
# File 'lib/mongo/event/description_changed.rb', line 25

def cluster
  @cluster
end

Instance Method Details

#handle(updated) ⇒ Object

This event publishes an event to add the cluster and logs the configuration change.

Examples:

Handle the event.

server_added.handle('127.0.0.1:27018')

Parameters:

Since:

  • 2.0.0



48
49
50
51
# File 'lib/mongo/event/description_changed.rb', line 48

def handle(updated)
  cluster.add_hosts(updated)
  cluster.remove_hosts(updated)
end