Module: Genome::Resource::ClassMethods
- Defined in:
- lib/genome/resource.rb
Instance Method Summary collapse
- #description(description) ⇒ Object
- #override_parameter(parameter_name, parameter_options = {}) ⇒ Object
- #parameter(parameter_name, parameter_options = {}) ⇒ Object
- #reference(resource_name) ⇒ Object
- #remove_dependencies(*dependencies) ⇒ Object
- #remove_template(template_name) ⇒ Object
- #shared_tags(*tags) ⇒ Object
- #tag(template_name, *tags) ⇒ Object
- #template(template_name, template_klass, template_properties) ⇒ Object
Instance Method Details
#description(description) ⇒ Object
38 39 40 |
# File 'lib/genome/resource.rb', line 38 def description(description) @resource_description = description end |
#override_parameter(parameter_name, parameter_options = {}) ⇒ Object
48 49 50 51 52 |
# File 'lib/genome/resource.rb', line 48 def override_parameter(parameter_name, = {}) raise Error::MissingParameterName, "Parameter name not defined '#{parameter_name}'" unless parameters.key?(parameter_name) parameters[parameter_name]..merge!() end |
#parameter(parameter_name, parameter_options = {}) ⇒ Object
42 43 44 45 46 |
# File 'lib/genome/resource.rb', line 42 def parameter(parameter_name, = {}) raise Error::DuplicateParameter, "Duplicate parameter name defined '#{parameter_name}'" if parameters.key?(parameter_name) parameters[parameter_name] = Parameter.new(parameter_name: parameter_name, parameter_options: ) end |
#reference(resource_name) ⇒ Object
75 76 77 |
# File 'lib/genome/resource.rb', line 75 def reference(resource_name) Reference.new(resource_name) end |
#remove_dependencies(*dependencies) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/genome/resource.rb', line 67 def remove_dependencies(*dependencies) templates.each do |template_name, template_parameters| dependencies.each do |dependency| template_parameters[:dependencies]&.delete(dependency) end end end |
#remove_template(template_name) ⇒ Object
33 34 35 36 |
# File 'lib/genome/resource.rb', line 33 def remove_template(template_name) templates.delete(template_name) remove_dependencies(template_name) end |
#shared_tags(*tags) ⇒ Object
54 55 56 57 58 |
# File 'lib/genome/resource.rb', line 54 def (*) templates.each do |template_name, template| tag(template_name, *) if template[:klass].property_configs.key?(:Tags) end end |
#tag(template_name, *tags) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/genome/resource.rb', line 60 def tag(template_name, *) template = templates[template_name] template[:properties][:Tags] ||= [] template[:properties][:Tags].concat() end |
#template(template_name, template_klass, template_properties) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/genome/resource.rb', line 21 def template(template_name, template_klass, template_properties) raise Error::DuplicateTemplate, "Duplicate template name defined '#{template_name}'" if templates.key?(template_name) dependencies = template_properties.delete(:DependsOn) templates[template_name] = { klass: template_klass, properties: template_properties, dependencies: dependencies, } end |