diff --git a/app/models/label_model.rb b/app/models/label_model.rb new file mode 100644 index 000000000..4fb427394 --- /dev/null +++ b/app/models/label_model.rb @@ -0,0 +1 @@ +LabelModel = Struct.new(:id, :label, keyword_init: true) diff --git a/app/models/zone.rb b/app/models/zone.rb index cf8c806c2..20829bc81 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -19,7 +19,7 @@ class Zone < ApplicationRecord def self.available_at(date, without_zones = []) (Zone.all - without_zones).filter { |zone| zone.available_at?(date) }.sort_by { |zone| zone.label_at(date) } .map do |zone| - OpenStruct.new(id: zone.id, label: zone.label_at(date)) + LabelModel.new(id: zone.id, label: zone.label_at(date)) end end