lib/gtfs/realtime/trip.rb in gtfs-realtime-0.3.0 vs lib/gtfs/realtime/trip.rb in gtfs-realtime-0.4.0

- old
+ new

@@ -1,15 +1,15 @@ module GTFS class Realtime class Trip < GTFS::Realtime::Model - many_to_one :route - many_to_many :stops, join_table: :gtfs_realtime_stop_times - one_to_many :calendar_dates, primary_key: :service_id, key: :service_id - one_to_many :shapes, primary_key: :shape_id, key: :id + belongs_to :route + has_many :stop_times + has_many :stops, through: :stop_times + has_many :calendar_dates, primary_key: :service_id, foreign_key: :service_id + has_many :shapes, primary_key: :shape_id, foreign_key: :id def active?(date) - # can't use .where chaining b/c Sequel is weird - calendar_dates.find{|cd| cd.exception_type == GTFS::Realtime::CalendarDate::ADDED && cd.date == date} + calendar_dates.where(exception_type: GTFS::Realtime::CalendarDate::ADDED, date: date).any? end end end end