Skip to content

Commit

Permalink
fix merge! from cops
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Jan 24, 2017
1 parent 3a6efb0 commit 5ff3b98
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/models/miq_report/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,21 @@ def include_as_hash(includes = include, klass = nil)
assoc_klass = assoc_reflection.nil? ? nil : (assoc_reflection.options[:polymorphic] ? k : assoc_reflection.klass)

if v.nil? || v["include"].blank?
result.merge!(k => {})
else
result.merge!(k => include_as_hash(v["include"], assoc_klass)) if assoc_klass
result[k] = {}
elsif assoc_klass
result[k] = include_as_hash(v["include"], assoc_klass)
end

v["columns"].each { |c| result[k].merge!(c.to_sym => {}) if assoc_klass.virtual_attribute?(c) } if assoc_klass && assoc_klass.respond_to?(:virtual_attribute?) && v["columns"]
if assoc_klass && assoc_klass.respond_to?(:virtual_attribute?) && v["columns"]
v["columns"].each do |c|
result[k][c.to_sym] = {} if assoc_klass.virtual_attribute?(c)
end
end
end
end
elsif includes.kind_of?(Array)
result ||= {}
includes.each { |i| result.merge!(i.to_sym => {}) }
includes.each { |i| result[i.to_sym] = {} }
end

result
Expand Down

0 comments on commit 5ff3b98

Please sign in to comment.