Class: Puppet::Pal::TaskSignature Private
- Defined in:
- lib/puppet/pal/task_signature.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A TaskSignature is returned from task_signature. Its purpose is to answer questions about the task's parameters
and if it can be run/called with a hash of named parameters.
Instance Method Summary collapse
-
#initialize(task) ⇒ TaskSignature
constructor
private
A new instance of TaskSignature.
-
#runnable_with?(args_hash) {|a| ... } ⇒ Boolean
private
Returns whether or not the given arguments are acceptable when running the task.
-
#task ⇒ Puppet::Pops::Types::PuppetObject
private
Returns the Task instance which can be further explored.
-
#task_hash ⇒ Hash{String=>Object}
private
Returns the Task instance as a hash.
Constructor Details
#initialize(task) ⇒ TaskSignature
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TaskSignature.
7 8 9 |
# File 'lib/puppet/pal/task_signature.rb', line 7 def initialize(task) @task = task end |
Instance Method Details
#runnable_with?(args_hash) {|a| ... } ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether or not the given arguments are acceptable when running the task. In addition to returning the boolean outcome, if a block is given, it is called with a string of formatted error messages that describes the difference between what was given and what is expected. The error message may have multiple lines of text, and each line is indented one space.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/puppet/pal/task_signature.rb', line 20 def runnable_with?(args_hash) params = @task.parameters params_type = if params.nil? T_GENERIC_TASK_HASH else Puppet::Pops::Types::TypeFactory.struct(params) end return true if params_type.instance?(args_hash) if block_given? tm = Puppet::Pops::Types::TypeMismatchDescriber.singleton error = if params.nil? tm.describe_mismatch('', params_type, Puppet::Pops::Types::TypeCalculator.infer_set(args_hash)) else tm.describe_struct_signature(params_type, args_hash).flatten.map {|e| e.format }.join("\n") end yield "Task #{@task.name}:\n#{error}" end false end |
#task ⇒ Puppet::Pops::Types::PuppetObject
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the Task instance which can be further explored. It contains all meta-data defined for the task such as the description, parameters, output, etc.
52 53 54 |
# File 'lib/puppet/pal/task_signature.rb', line 52 def task @task end |
#task_hash ⇒ Hash{String=>Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the Task instance as a hash
44 45 46 |
# File 'lib/puppet/pal/task_signature.rb', line 44 def task_hash @task._pcore_init_hash end |