~ubuntu-branches/ubuntu/utopic/ctioga2/utopic

« back to all changes in this revision

Viewing changes to lib/ctioga2/data/backends/factory.rb

  • Committer: Package Import Robot
  • Author(s): Vincent Fourmond
  • Date: 2013-12-27 21:04:22 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131227210422-a3f0c7alorq6lwq2
Tags: 0.8-1
* New upstream release
* Updated URLs and debian/watch to follow its new location
* Already conforms to standards 3.9.5
* Finally updated VCS URLS

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17
17
 
18
18
require 'ctioga2/utils'
 
19
require 'ctioga2/log'
19
20
require 'ctioga2/data/backends/backend'
20
21
 
21
22
module CTioga2
22
23
 
23
 
  Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
24
 
 
25
24
  module Data
26
25
 
27
26
    module Backends
30
29
      # available, and features a 'current backend'.
31
30
      class BackendFactory
32
31
 
 
32
        include Log
 
33
 
33
34
        # A hash name (as in Description#name) -> Backend
34
35
        attr_accessor :backends
35
36
 
58
59
          @current = @backends[backend]
59
60
        end
60
61
 
 
62
        # Returns the backend named in the 'as' key of options, or the
 
63
        # current backend if there isn't
 
64
        def specified_backend(options = {})
 
65
          if options.key? 'as'
 
66
            k = options['as']
 
67
            if @backends.key? k
 
68
              return @backends[k]
 
69
            else
 
70
              error { "No such backend: #{k}, ignoring" }
 
71
            end
 
72
          else
 
73
            return @current
 
74
          end
 
75
        end
 
76
 
61
77
        
62
78
        # Sets the (raw) value of the parameter of the given backend
63
79
        def set_backend_parameter_value(backend, param, value)