diff options
| author | Teddy Wing | 2018-03-14 11:02:42 +0100 |
|---|---|---|
| committer | Luc Donnet | 2018-03-23 17:16:43 +0100 |
| commit | 1b1d9f015d9b416a638f699981f2c83fcf87f641 (patch) | |
| tree | d292dd3b1e1792c9e7cedc3b29735f9537b52c5e | |
| parent | 504e2864a494aa6767da95892dd14ce0b567e2cf (diff) | |
| download | chouette-core-1b1d9f015d9b416a638f699981f2c83fcf87f641.tar.bz2 | |
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
| -rw-r--r-- | app/models/chouette/route.rb | 3 |
1 files changed, 1 insertions, 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) |
