Skip to content

Commit

Permalink
Merge pull request #13 from Sage/bugfix_fix_alias_recursion
Browse files Browse the repository at this point in the history
added bugfix to resolve issue with alias recursion
  • Loading branch information
vaughanbrittonsage authored Feb 19, 2018
2 parents 9dcc3c8 + ceaa57f commit 552fd6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/class_kit/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 552fd6a

Please sign in to comment.