Sha256: 1117a4d755434c47a3ddadb749610e718868d41aae2ac72fe2ac52a3c4ff8d7f
Contents?: true
Size: 1.28 KB
Versions: 75
Compression:
Stored size: 1.28 KB
Contents
module HQMF module Conversion module Utilities def build_hash(source, elements) hash = {} elements.each do |element| value = source.send(element) hash[element] = value unless value.nil? end hash end def json_array(elements) return nil if elements.nil? array = [] elements.each do |element| if (element.is_a? OpenStruct) array << openstruct_to_json(element) else array << element.to_json end end array.compact! (array.empty?) ? nil : array end def openstruct_to_json(element) json = {} element.marshal_dump.each do |key,value| if value.is_a? OpenStruct json[key] = openstruct_to_json(value) elsif (value.class.to_s.split("::").first.start_with? 'HQMF') json[key] = value.to_json else json[key] = value end end json end def check_equality(left,right) same = true left.instance_variables.each do |variable| same &&= left.instance_variable_get(variable) == right.instance_variable_get(variable) end same end end end end
Version data entries
75 entries across 75 versions & 3 rubygems