aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/export/netex.rb
blob: bacc7e60fc8e1bf67095b96918533d02d6fc7be5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Export::Netex < Export::Base
  after_commit :call_iev_callback, on: :create
  option :export_subtype, collection: %w(line full), required: true do |val|
    val.full do
      option :duration, type: :integer, default_value: 90, required: true
    end
    val.line do
      option :line_code, collection: ->(referential){referential.lines}, depends_on_referential: true
    end
  end

  private

  def iev_callback_url
    URI("#{Rails.configuration.iev_url}/boiv_iev/referentials/exporter/new?id=#{id}")
  end

  def destroy_non_ready_referential
    if referential && !referential.ready
      referential.destroy
    end
  end
end