From 1b1d9f015d9b416a638f699981f2c83fcf87f641 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 14 Mar 2018 11:02:42 +0100 Subject: Route#duplicate: Use `#slice!` instead of `#slice` Johan suggested simplifying this method by changing the `slice` call: http://api.rubyonrails.org/classes/Hash.html#method-i-slice-21 I had modified this to fix the whitespace while working on the `WayCost` calculation function for `Chouette::Route`s, so don't really have a brain cache hit on this code, but the change makes sense and seems to work. Refs #6095 --- app/models/chouette/route.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 01358e8aa..4b1b88543 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -82,9 +82,8 @@ module Chouette 'opposite_route_id' => nil, 'name' => I18n.t('activerecord.copy', name: self.name) } - keys_for_create = attributes.keys - %w{id objectid created_at updated_at} atts_for_create = attributes - .slice(*keys_for_create) + .slice!(*%w{id objectid created_at updated_at}) .merge(overrides) new_route = self.class.create!(atts_for_create) duplicate_stop_points(for_route: new_route) -- cgit v1.2.3