Class: Nps::Utils
- Inherits:
-
Object
- Object
- Nps::Utils
- Defined in:
- lib/nps/utils.rb
Constant Summary collapse
- SDK =
{language: 'Ruby', version: RUBY_VERSION}
- API_VERSION =
{version: '1'}
- CACHE_TTL =
1- TIMEOUT =
90
Class Method Summary collapse
- .check_sanitize(params, is_root, nodo, file) ⇒ Object
- .check_sanitize_array(params, nodo, file) ⇒ Object
- .sanitize(params) ⇒ Object
- .validate_size(value, k, nodo, file) ⇒ Object
Class Method Details
.check_sanitize(params, is_root, nodo, file) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nps/utils.rb', line 15 def self.check_sanitize(params, is_root, nodo, file) if is_root result_params = {} else result_params = params end params.each do |k, v| if v.is_a?(Hash) result_params[k] = check_sanitize(v, false, k, file) elsif v.is_a?(Array) result_params[k] = check_sanitize_array(v, k, file) else result_params[k] = validate_size(v, k, nodo, file) end end return result_params end |
.check_sanitize_array(params, nodo, file) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/nps/utils.rb', line 33 def self.check_sanitize_array(params, nodo, file) result_params = [] params.each { |x| result_params.push(check_sanitize(x, false, nodo, file)) } return result_params end |
.sanitize(params) ⇒ Object
9 10 11 12 13 |
# File 'lib/nps/utils.rb', line 9 def self.sanitize(params) #File.join(File.dirname(File.expand_path(__FILE__)), "/wsdl/" + @wsdl) = IniFile.load(File.join(File.dirname(File.(__FILE__)), "conf/sanitize_struc.ini")) return check_sanitize(params, true, nil, ) end |
.validate_size(value, k, nodo, file) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/nps/utils.rb', line 40 def self.validate_size(value, k, nodo, file) if nodo != nil key_name = nodo.to_s + "." + k + ".max_length" else key_name = k + ".max_length" end size = file["global"][key_name] if size.nil? return value end return value.to_s.slice(0,size) end |