Class: OmfEc::AppDefinition
- Inherits:
-
Object
- Object
- OmfEc::AppDefinition
- Includes:
- Backward::AppDefinition
- Defined in:
- lib/omf_ec/app_definition.rb
Overview
Application Definition used in experiment script
Instance Attribute Summary collapse
-
#name ⇒ Object
TODO: eventually this call would mirror all the properties of the App Proxy right now we just have name, binary_path, parameters.
-
#properties ⇒ Object
TODO: eventually this call would mirror all the properties of the App Proxy right now we just have name, binary_path, parameters.
Instance Method Summary collapse
- #define_measurement_point(mp) ⇒ Object
-
#define_parameter(params) ⇒ Object
Add new parameter(s) to this Application Definition.
-
#initialize(name) ⇒ AppDefinition
constructor
A new instance of AppDefinition.
- #method_missing(method_name, *args) ⇒ Object
- #path=(arg) ⇒ Object
- #shortDescription=(arg) ⇒ Object
Methods included from Backward::AppDefinition
#defMeasurement, #defMetric, #defProperty
Constructor Details
#initialize(name) ⇒ AppDefinition
Returns a new instance of AppDefinition.
19 20 21 22 |
# File 'lib/omf_ec/app_definition.rb', line 19 def initialize(name) self.name = name self.properties = Hashie::Mash.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/omf_ec/app_definition.rb', line 61 def method_missing(method_name, *args) k = method_name.to_sym return @properties[k] if @properties.key?(k) m = method_name.to_s.match(/(.*?)([=]?)$/) if m[2] == '=' @properties[m[1].to_sym] = args.first else super end end |
Instance Attribute Details
#name ⇒ Object
TODO: eventually this call would mirror all the properties of the App Proxy right now we just have name, binary_path, parameters
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/omf_ec/app_definition.rb', line 12 class AppDefinition # TODO: eventually this call would mirror all the properties of the App Proxy # right now we just have name, binary_path, parameters attr_accessor :name, :properties # @param [String] name name of the application to define def initialize(name) self.name = name self.properties = Hashie::Mash.new end # Add new parameter(s) to this Application Definition # # @param [Hash] params a hash with the parameters to add # def define_parameter(params) @properties[:parameters] = Hashie::Mash.new unless @properties.key?(:parameters) if params.kind_of? Hash @properties[:parameters].merge!(params) else error "Cannot define parameter for app '#{self.name}'! Parameter "+ "not passed as a Hash ('#{params.inspect}')" end end def define_measurement_point(mp) @properties[:oml] = Hashie::Mash.new unless @properties.key?(:oml) if mp.kind_of? Hash @properties[:oml][:available_mps] = Array.new unless @properties[:oml].key?(:available_mps) @properties[:oml][:available_mps] << mp else error "Cannot define Measurement Point for app '#{self.name}'! MP "+ "not passed as a Hash ('#{mp.inspect}')" end end warn_removed :version def path=(arg) @properties[:binary_path] = arg warn_deprecation :path=, :binary_path= end def shortDescription=(arg) @properties[:description] = arg warn_deprecation :shortDescription=, :description= end def method_missing(method_name, *args) k = method_name.to_sym return @properties[k] if @properties.key?(k) m = method_name.to_s.match(/(.*?)([=]?)$/) if m[2] == '=' @properties[m[1].to_sym] = args.first else super end end include OmfEc::Backward::AppDefinition end |
#properties ⇒ Object
TODO: eventually this call would mirror all the properties of the App Proxy right now we just have name, binary_path, parameters
16 17 18 |
# File 'lib/omf_ec/app_definition.rb', line 16 def properties @properties end |
Instance Method Details
#define_measurement_point(mp) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/omf_ec/app_definition.rb', line 38 def define_measurement_point(mp) @properties[:oml] = Hashie::Mash.new unless @properties.key?(:oml) if mp.kind_of? Hash @properties[:oml][:available_mps] = Array.new unless @properties[:oml].key?(:available_mps) @properties[:oml][:available_mps] << mp else error "Cannot define Measurement Point for app '#{self.name}'! MP "+ "not passed as a Hash ('#{mp.inspect}')" end end |
#define_parameter(params) ⇒ Object
Add new parameter(s) to this Application Definition
28 29 30 31 32 33 34 35 36 |
# File 'lib/omf_ec/app_definition.rb', line 28 def define_parameter(params) @properties[:parameters] = Hashie::Mash.new unless @properties.key?(:parameters) if params.kind_of? Hash @properties[:parameters].merge!(params) else error "Cannot define parameter for app '#{self.name}'! Parameter "+ "not passed as a Hash ('#{params.inspect}')" end end |
#path=(arg) ⇒ Object
51 52 53 54 |
# File 'lib/omf_ec/app_definition.rb', line 51 def path=(arg) @properties[:binary_path] = arg warn_deprecation :path=, :binary_path= end |
#shortDescription=(arg) ⇒ Object
56 57 58 59 |
# File 'lib/omf_ec/app_definition.rb', line 56 def shortDescription=(arg) @properties[:description] = arg warn_deprecation :shortDescription=, :description= end |