From ceaa57f705dfe213868b6019d2c34b1d8e70b123 Mon Sep 17 00:00:00 2001 From: vaughanbrittonsage Date: Mon, 19 Feb 2018 14:26:19 +0000 Subject: [PATCH] added bugfix to resolve issue with alias recursion --- lib/class_kit/helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/class_kit/helper.rb b/lib/class_kit/helper.rb index 91f3de7..4619769 100644 --- a/lib/class_kit/helper.rb +++ b/lib/class_kit/helper.rb @@ -29,11 +29,11 @@ def to_hash(object, use_alias = false) value = object.public_send(attribute[:name]) if value != nil hash[key] = if is_class_kit?(type) - to_hash(value) + to_hash(value, use_alias) elsif type == Array value.map do |i| if is_class_kit?(i.class) - to_hash(i) + to_hash(i, use_alias) else i end @@ -62,14 +62,14 @@ def from_hash(hash:, klass:, use_alias: false) next if hash[key].nil? value = if is_class_kit?(type) - from_hash(hash: hash[key], klass: type) + from_hash(hash: hash[key], klass: type, use_alias: use_alias) elsif type == Array hash[key].map do |array_element| if attribute[:collection_type].nil? array_element else if is_class_kit?(attribute[:collection_type]) - from_hash(hash: array_element, klass: attribute[:collection_type]) + from_hash(hash: array_element, klass: attribute[:collection_type], use_alias: use_alias) else @value_helper.parse(type: attribute[:collection_type], value: array_element) end