Module: TronHttp::Helpers

Defined in:
lib/tron_http/helpers.rb

Overview

Helpers

Class Method Summary collapse

Class Method Details

.validate_variables(vars_reference, vars_given) ⇒ Object

Checks each variable against the given variables. If type name includes a ! then it is required. If not and a variable is not present then it is ignored.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tron_http/helpers.rb', line 10

def self.validate_variables(vars_reference, vars_given)
  return {} unless vars_reference

  vars_reference.each do |name, type|
    next unless type[-1] == "!" && vars_given[name.to_sym].nil?

    raise "Missing required variable #{name} of type #{type}."
  end

  vars_given
end