From 546a4e9e21afaa0182108d1a1b47edfb3df2be0b Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Thu, 10 Apr 2008 10:47:17 -0600 Subject: allow properties to be set, as well as queried --- lib/net/ssh/multi/dynamic_server.rb | 6 ++++++ lib/net/ssh/multi/server.rb | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/net/ssh/multi/dynamic_server.rb b/lib/net/ssh/multi/dynamic_server.rb index 0fec55a..cbdde2b 100644 --- a/lib/net/ssh/multi/dynamic_server.rb +++ b/lib/net/ssh/multi/dynamic_server.rb @@ -40,6 +40,12 @@ module Net; module SSH; module Multi (options[:properties] ||= {})[key] end + # Sets the given key/value pair in the +:properties+ key in the options + # hash. If the options hash has no :properties key, it will be created. + def []=(key, value) + (options[:properties] ||= {})[key] = value + end + # Iterates over every instantiated server record in this dynamic server. # If the servers have not yet been instantiated, this does nothing (e.g., # it does _not_ automatically invoke #evaluate!). diff --git a/lib/net/ssh/multi/server.rb b/lib/net/ssh/multi/server.rb index f53adb8..41fd97c 100644 --- a/lib/net/ssh/multi/server.rb +++ b/lib/net/ssh/multi/server.rb @@ -61,7 +61,13 @@ module Net; module SSH; module Multi # properties are described via the +:properties+ key in the options hash # when defining the Server. def [](key) - (options[:properties] ||= {})[key] + (options[:properties] || {})[key] + end + + # Sets the given key/value pair in the +:properties+ key in the options + # hash. If the options hash has no :properties key, it will be created. + def []=(key, value) + (options[:properties] ||= {})[key] = value end # Returns the port number to use for this connection. -- cgit v1.2.1