Skip to content

Commit ab6d8e9

Browse files
committed
Lint: Use to_h { ... } instead of each_with_object
This commit updates the `hashable` extension to satisfy the Rubocop Style/ReduceToHash check. Signed-off-by: Charlie Sharpsteen <charlie@overlookinfratech.com>
1 parent 4e9267e commit ab6d8e9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/vanagon/extensions/hashable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module HashableAttributes
77
# @return [Hash] Converts an object to a hash with keys representing
88
# each attribute (as symbols) and their corresponding values
99
def to_hash
10-
instance_variables.each_with_object({}) do |var, hash|
11-
hash[var.to_s.delete("@")] = instance_variable_get(var)
10+
instance_variables.to_h do |var|
11+
[var.to_s.delete("@"), instance_variable_get(var)]
1212
end
1313
end
1414
alias_method :to_h, :to_hash

0 commit comments

Comments
 (0)