Class: Specify::Configuration::HostConfig
- Defined in:
- lib/specify/configuration/host_config.rb
Overview
HostConfigs are configurations that map file directories to host names.
Instance Attribute Summary
Attributes inherited from Config
Instance Method Summary collapse
-
#directory?(directory) ⇒ Boolean
Returns
trueifdirectoryis mapped to a host name. -
#initialize(file = nil) ⇒ HostConfig
constructor
Retutrns a new HostConfig for
file(a YAML file). -
#map_directory(directory, host) ⇒ Object
Maps
directorytohost. -
#params ⇒ Object
Returns a Hash with the parameters for the current directory mappings from the configuration YAML file.
-
#resolve_host(directory) ⇒ Object
Returns the host name that is mapped to
directory.
Methods inherited from Config
#add_database, #add_host, empty, #save, #saved?, #touch
Constructor Details
#initialize(file = nil) ⇒ HostConfig
Retutrns a new HostConfig for file (a YAML file).
8 9 10 11 |
# File 'lib/specify/configuration/host_config.rb', line 8 def initialize(file = nil) super(file) @saved = true end |
Instance Method Details
#directory?(directory) ⇒ Boolean
Returns true if directory is mapped to a host name.
14 15 16 |
# File 'lib/specify/configuration/host_config.rb', line 14 def directory?(directory) params.key? directory end |
#map_directory(directory, host) ⇒ Object
Maps directory to host.
19 20 21 22 23 |
# File 'lib/specify/configuration/host_config.rb', line 19 def map_directory(directory, host) raise "Directory '#{directory}' already mapped" if params[directory] params[directory] = host touch end |
#params ⇒ Object
Returns a Hash with the parameters for the current directory mappings from the configuration YAML file.
27 28 29 |
# File 'lib/specify/configuration/host_config.rb', line 27 def params super.fetch :dir_names end |
#resolve_host(directory) ⇒ Object
Returns the host name that is mapped to directory
32 33 34 |
# File 'lib/specify/configuration/host_config.rb', line 32 def resolve_host(directory) params.fetch directory end |