lib/alba/conditional_attribute.rb in alba-3.0.0 vs lib/alba/conditional_attribute.rb in alba-3.0.1
- old
+ new
@@ -49,10 +49,12 @@
@condition.is_a?(Proc) && @condition.arity >= 2
end
# OpenStruct is used as a simple solution for converting Hash or Array of Hash into an object
# Using OpenStruct is not good in general, but in this case there's no other solution
+ # rubocop:disable Style/OpenStructUse
+ # rubocop:disable Performance/OpenStruct
def objectize(fetched_attribute)
return fetched_attribute unless @body.is_a?(Alba::Association)
if fetched_attribute.is_a?(Array)
fetched_attribute.map do |hash|
@@ -60,7 +62,9 @@
end
else
OpenStruct.new(fetched_attribute)
end
end
+ # rubocop:enable Style/OpenStructUse
+ # rubocop:enable Performance/OpenStruct
end
end