Class: Machinery::WorkloadMapperDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/workload_mapper_dsl.rb

Overview

Copyright © 2013-2016 SUSE LLC

This program is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, contact SUSE LLC.

To contact SUSE about this file by physical or electronic mail, you may find current contact information at www.suse.com

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(system) ⇒ WorkloadMapperDSL

Returns a new instance of WorkloadMapperDSL.



20
21
22
23
24
# File 'lib/workload_mapper_dsl.rb', line 20

def initialize(system)
  @system = system
  @parameters = {}
  @data = {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



18
19
20
# File 'lib/workload_mapper_dsl.rb', line 18

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/workload_mapper_dsl.rb', line 18

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



18
19
20
# File 'lib/workload_mapper_dsl.rb', line 18

def parameters
  @parameters
end

#serviceObject (readonly)

Returns the value of attribute service.



18
19
20
# File 'lib/workload_mapper_dsl.rb', line 18

def service
  @service
end

#systemObject (readonly)

Returns the value of attribute system.



18
19
20
# File 'lib/workload_mapper_dsl.rb', line 18

def system
  @system
end

Instance Method Details

#check_clue(clue) ⇒ Object



50
51
52
53
# File 'lib/workload_mapper_dsl.rb', line 50

def check_clue(clue)
  instance_eval(clue)
  self
end

#extract(origin, destination) ⇒ Object



35
36
37
# File 'lib/workload_mapper_dsl.rb', line 35

def extract(origin, destination)
  @data[origin] = destination
end

#identify(name, service = nil) ⇒ Object



26
27
28
29
# File 'lib/workload_mapper_dsl.rb', line 26

def identify(name, service = nil)
  @name = name
  @service = !!service ? service : name
end

#parameter(name, value) ⇒ Object



31
32
33
# File 'lib/workload_mapper_dsl.rb', line 31

def parameter(name, value)
  @parameters[name] = value
end

#to_hObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/workload_mapper_dsl.rb', line 39

def to_h
  return {} unless service
  {
    name => {
      "service" => service,
      "parameters" => parameters,
      "data" => data
    }
  }
end