aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/stop_area_referential.rb
blob: 5603399cceaa855fea2c9df7b6d352af0268514d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class StopAreaReferential < ActiveRecord::Base
  include ObjectidFormatterSupport
  has_many :stop_area_referential_memberships
  has_many :organisations, through: :stop_area_referential_memberships

  has_many :stop_areas, class_name: 'Chouette::StopArea'
  has_many :stop_area_referential_syncs, -> {order created_at: :desc}
  has_many :workbenches
  has_one  :workgroup

  def add_member(organisation, options = {})
    attributes = options.merge organisation: organisation
    stop_area_referential_memberships.build attributes
  end

  def last_sync
    stop_area_referential_syncs.last
  end
end