Class: Dataloaderb::ProcessDefinition
- Inherits:
-
Object
- Object
- Dataloaderb::ProcessDefinition
- Defined in:
- lib/dataloaderb/process_definition.rb
Instance Attribute Summary (collapse)
-
- (Object) description
readonly
Returns the value of attribute description.
-
- (Object) entries
readonly
Returns the value of attribute entries.
-
- (Object) id
readonly
Returns the value of attribute id.
Instance Method Summary (collapse)
- - (Object) get(key)
-
- (ProcessDefinition) initialize(yaml, merge = nil)
constructor
Create a new instance of a ConfCreator.
-
- (Object) load_yaml(yaml_file, merge = nil)
Load a process definition from a Yaml file.
- - (Object) set(key, value)
Constructor Details
- (ProcessDefinition) initialize(yaml, merge = nil)
Create a new instance of a ConfCreator
9 10 11 12 13 14 |
# File 'lib/dataloaderb/process_definition.rb', line 9 def initialize(yaml, merge = nil) @id = '' @description = '' @entries = {} load_yaml(yaml, merge) end |
Instance Attribute Details
- (Object) description (readonly)
Returns the value of attribute description
5 6 7 |
# File 'lib/dataloaderb/process_definition.rb', line 5 def description @description end |
- (Object) entries (readonly)
Returns the value of attribute entries
6 7 8 |
# File 'lib/dataloaderb/process_definition.rb', line 6 def entries @entries end |
- (Object) id (readonly)
Returns the value of attribute id
4 5 6 |
# File 'lib/dataloaderb/process_definition.rb', line 4 def id @id end |
Instance Method Details
- (Object) get(key)
20 21 22 |
# File 'lib/dataloaderb/process_definition.rb', line 20 def get(key) @entries[key] end |
- (Object) load_yaml(yaml_file, merge = nil)
Load a process definition from a Yaml file
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dataloaderb/process_definition.rb', line 25 def load_yaml(yaml_file, merge = nil) raise ArgumentError, "Cannot find file #{yaml_file}" unless File.exist?(yaml_file) raise ArgumentError, "Cannot find file #{merge}" unless merge.nil? || File.exist?(merge) unless merge.nil? merge_data = YAML.load_file(merge) merge_data.each do |key, value| self.set(key, value) end end proc = YAML.load_file(yaml_file) @id = proc['id'] @description = proc['description'] proc['properties'].each do |key, value| self.set(key, value) end end |
- (Object) set(key, value)
16 17 18 |
# File 'lib/dataloaderb/process_definition.rb', line 16 def set(key, value) @entries[key] = value end |