Skip to content

Commit

Permalink
Fix deprecation warning of Enumerable#sum
Browse files Browse the repository at this point in the history
```
DEPRECATION WARNING: Rails 7.0 has deprecated Enumerable.sum in favor of Ruby's native implementation available since 2.4. Sum of non-numeric elements requires an initial argument.
```
  • Loading branch information
yujideveloper committed Aug 16, 2022
1 parent 18d242f commit bb11159
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_file/hash_and_array_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def data_from_multiple_files
loaded_files = full_paths.collect { |path| load_path(path) }

if loaded_files.all?{ |file_data| file_data.is_a?(Array) }
loaded_files.sum
loaded_files.sum([])
elsif loaded_files.all?{ |file_data| file_data.is_a?(Hash) }
loaded_files.inject({}) { |hash, file_data| hash.merge(file_data) }
else
Expand Down

0 comments on commit bb11159

Please sign in to comment.