blob: 4a21cbccf0cafc610eeb695731daffd67e4b48f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
module RouteRestrictions
extend ActiveSupport::Concern
included do
include ObjectidRestrictions
validate :max_instance_limitation, :wayback_code_limitation
# HUB-37
def wayback_code_limitation
return unless hub_restricted?
errors.add( :wayback, I18n.t('hub.routes.wayback_code_exclusive')) if line.routes.reject {|r| r.id==id}.map(&:wayback).include?( wayback)
end
# HUB-37
def max_instance_limitation
return unless hub_restricted?
errors.add( :flash, I18n.t('hub.routes.max_by_line')) if 2 < line.routes.size
end
# HUB-38
with_options if: :hub_restricted? do |route|
route.validates_format_of :objectid, :with => %r{\A\w+:\w+:([\w]{1,8}|__pending_id__\d+)\z}
end
end
end
|