module Subroutine::Outputs

Public Instance Methods

get_output(name) click to toggle source
# File lib/subroutine/outputs.rb, line 61
def get_output(name)
  name = name.to_sym
  raise ::Subroutine::Outputs::UnknownOutputError, name unless output_configurations.key?(name)

  outputs[name]
end
output(name, value) click to toggle source
# File lib/subroutine/outputs.rb, line 52
def output(name, value)
  name = name.to_sym
  unless output_configurations.key?(name)
    raise ::Subroutine::Outputs::UnknownOutputError, name
  end

  outputs[name] = value
end
output_provided?(name) click to toggle source
# File lib/subroutine/outputs.rb, line 42
def output_provided?(name)
  name = name.to_sym

  unless output_configurations.key?(name)
    raise ::Subroutine::Outputs::UnknownOutputError, name
  end

  outputs.key?(name)
end
setup_outputs() click to toggle source
# File lib/subroutine/outputs.rb, line 38
def setup_outputs
  @outputs = {} # don't do with_indifferent_access because it will turn provided objects into with_indifferent_access objects, which may not be the desired behavior
end
validate_outputs!() click to toggle source
# File lib/subroutine/outputs.rb, line 68
def validate_outputs!
  output_configurations.each_pair do |name, config|
    if config.required? && !output_provided?(name)
      raise ::Subroutine::Outputs::OutputNotSetError, name
    end
  end
end