class CTioga2::Data::Backends::BackendFactory
This class holds an instance of all the different Backend
available, and features a 'current backend'.
Attributes
backends[RW]
A hash name (as in Description#name) -> Backend
current[RW]
The current Backend
Public Class Methods
new(default)
click to toggle source
Creates a new BackendFactory
# File lib/ctioga2/data/backends/factory.rb, line 41 def initialize(default) @backends = {} @backend_descriptions = Backend.list_backends for backend in @backend_descriptions.keys reset_backend(backend) # Add commands @backend_descriptions[backend].create_backend_commands end @current = @backends[default] end
Public Instance Methods
reset_backend(backend)
click to toggle source
Resets the given backend to its default values.
# File lib/ctioga2/data/backends/factory.rb, line 53 def reset_backend(backend) @backends[backend] = @backend_descriptions[backend].instantiate end
set_backend_parameter_value(backend, param, value)
click to toggle source
Sets the (raw) value of the parameter of the given backend
# File lib/ctioga2/data/backends/factory.rb, line 79 def set_backend_parameter_value(backend, param, value) b = @backends[backend] # This is way too complicated ! b.description.param_hash[param].set_value(b, value) end
set_current_backend(backend)
click to toggle source
Selects the current backend
# File lib/ctioga2/data/backends/factory.rb, line 58 def set_current_backend(backend) @current = @backends[backend] end
specified_backend(options = {})
click to toggle source
Returns the backend named in the 'as' key of options, or the current backend if there isn't
# File lib/ctioga2/data/backends/factory.rb, line 64 def specified_backend(options = {}) if options.key? 'as' k = options['as'] if @backends.key? k return @backends[k] else error { "No such backend: #{k}, ignoring" } end else return @current end end