aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorLuc Donnet2017-10-02 23:17:15 +0200
committerGitHub2017-10-02 23:17:15 +0200
commit6ba2b9f05961a33a6936d32e4c28d70149b48342 (patch)
tree457ebbf41a48873eb80cf4105bd993e69c8d711d /app/models
parentcba31dc411ceb47f80202c1d3a32a2e031630b13 (diff)
parent88567b111cf172e7b4368ffc02cb1e5cf27b4231 (diff)
downloadchouette-core-6ba2b9f05961a33a6936d32e4c28d70149b48342.tar.bz2
Merge pull request #82 from af83/4627-compliance-fix-class-vars
4627 compliance fix class vars
Diffstat (limited to 'app/models')
-rw-r--r--app/models/compliance_control.rb29
-rw-r--r--app/models/generic_attribute_control/min_max.rb10
-rw-r--r--app/models/generic_attribute_control/pattern.rb10
-rw-r--r--app/models/generic_attribute_control/uniqueness.rb10
-rw-r--r--app/models/journey_pattern_control/duplicates.rb3
-rw-r--r--app/models/journey_pattern_control/vehicle_journey.rb5
-rw-r--r--app/models/line_control/route.rb5
-rw-r--r--app/models/route_control/duplicates.rb3
-rw-r--r--app/models/route_control/journey_pattern.rb5
-rw-r--r--app/models/route_control/minimum_length.rb3
-rw-r--r--app/models/route_control/omnibus_journey_pattern.rb3
-rw-r--r--app/models/route_control/opposite_route.rb3
-rw-r--r--app/models/route_control/opposite_route_terminus.rb5
-rw-r--r--app/models/route_control/speed.rb5
-rw-r--r--app/models/route_control/stop_points_in_journey_pattern.rb5
-rw-r--r--app/models/route_control/time_table.rb5
-rw-r--r--app/models/route_control/unactivated_stop_points.rb5
-rw-r--r--app/models/route_control/vehicle_journey_at_stops.rb5
-rw-r--r--app/models/route_control/zdl_stop_area.rb3
-rw-r--r--app/models/routing_constaint_zone_control/maximum_length.rb7
-rw-r--r--app/models/routing_constaint_zone_control/minimum_length.rb7
-rw-r--r--app/models/routing_constaint_zone_control/unactivated_stop_point.rb7
-rw-r--r--app/models/routing_constraint_zone_control/maximum_length.rb6
-rw-r--r--app/models/routing_constraint_zone_control/minimum_length.rb6
-rw-r--r--app/models/routing_constraint_zone_control/unactivated_stop_point.rb6
-rw-r--r--app/models/vechicle_journey_control/waiting_time.rb7
-rw-r--r--app/models/vehicle_journey_control/delta.rb (renamed from app/models/vechicle_journey_control/delta.rb)3
-rw-r--r--app/models/vehicle_journey_control/waiting_time.rb6
28 files changed, 82 insertions, 95 deletions
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 42f45b6ca..0860f07b6 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -3,9 +3,6 @@ class ComplianceControl < ActiveRecord::Base
belongs_to :compliance_control_set
belongs_to :compliance_control_block
- @@default_criticity = :warning
- @@default_code = ""
-
enumerize :criticity, in: %i(info warning error), scope: true, default: :info
validates :criticity, presence: true
@@ -14,24 +11,28 @@ class ComplianceControl < ActiveRecord::Base
validates :origin_code, presence: true
validates :compliance_control_set, presence: true
- def self.policy_class
- ComplianceControlPolicy
- end
+ class << self
+ def default_criticity; :warning end
+ def default_code; "" end
+
+ def policy_class
+ ComplianceControlPolicy
+ end
- def self.inherited(child)
- child.instance_eval do
- def model_name
- ComplianceControl.model_name
+ def inherited(child)
+ child.instance_eval do
+ def model_name
+ ComplianceControl.model_name
+ end
end
+ super
end
- super
end
before_validation(on: :create) do
self.name ||= self.class.name
- self.code ||= @@default_code
- self.origin_code ||= @@default_code
- self.criticity ||= @@default_criticity
+ self.code ||= self.class.default_code
+ self.origin_code ||= self.class.default_code
end
end
diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb
index 6a2e1f284..0b0e5a9a7 100644
--- a/app/models/generic_attribute_control/min_max.rb
+++ b/app/models/generic_attribute_control/min_max.rb
@@ -2,16 +2,18 @@ module GenericAttributeControl
class MinMax < ComplianceControl
hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
- @@default_criticity = :warning
- @@default_code = "3-Generic-2"
validate :min_max_values
def min_max_values
true
end
- def self.dynamic_attributes
- self.hstore_metadata_for_control_attributes.keys
+ class << self
+ def default_criticity; :warning end
+ def default_code; "3-Generic-2" end
+ def dynamic_attributes
+ hstore_metadata_for_control_attributes.keys
+ end
end
end
end
diff --git a/app/models/generic_attribute_control/pattern.rb b/app/models/generic_attribute_control/pattern.rb
index 5b27da54e..72bb1770a 100644
--- a/app/models/generic_attribute_control/pattern.rb
+++ b/app/models/generic_attribute_control/pattern.rb
@@ -2,12 +2,14 @@ module GenericAttributeControl
class Pattern < ComplianceControl
hstore_accessor :control_attributes, value: :string, pattern: :string
- @@default_criticity = :warning
- @@default_code = "3-Generic-3"
-
validate :pattern_match
def pattern_match
true
end
+
+ class << self
+ def default_criticity; :warning end
+ def default_code; "3-Generic-3" end
+ end
end
-end \ No newline at end of file
+end
diff --git a/app/models/generic_attribute_control/uniqueness.rb b/app/models/generic_attribute_control/uniqueness.rb
index 4f1a82083..6ffe78565 100644
--- a/app/models/generic_attribute_control/uniqueness.rb
+++ b/app/models/generic_attribute_control/uniqueness.rb
@@ -2,12 +2,14 @@ module GenericAttributeControl
class Uniqueness < ComplianceControl
hstore_accessor :control_attributes, name: :string
- @@default_criticity = :warning
- @@default_code = "3-Generic-3"
-
validate :unique_values
def unique_values
true
end
+
+ class << self
+ def default_criticity; :warning end
+ def default_code; "3-Generic-3" end
+ end
end
-end \ No newline at end of file
+end
diff --git a/app/models/journey_pattern_control/duplicates.rb b/app/models/journey_pattern_control/duplicates.rb
index d3908cfc0..e06e6021b 100644
--- a/app/models/journey_pattern_control/duplicates.rb
+++ b/app/models/journey_pattern_control/duplicates.rb
@@ -1,7 +1,6 @@
module JourneyPatternControl
class Duplicates < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-JourneyPattern-1"
+ def self.default_code; "3-JourneyPattern-1" end
end
end
diff --git a/app/models/journey_pattern_control/vehicle_journey.rb b/app/models/journey_pattern_control/vehicle_journey.rb
index d7151f147..dfaf42beb 100644
--- a/app/models/journey_pattern_control/vehicle_journey.rb
+++ b/app/models/journey_pattern_control/vehicle_journey.rb
@@ -1,7 +1,6 @@
module JourneyPatternControl
class VehicleJourney < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-JourneyPattern-2"
+ def self.default_code; "3-JourneyPattern-2" end
end
-end \ No newline at end of file
+end
diff --git a/app/models/line_control/route.rb b/app/models/line_control/route.rb
index 21c5eca06..aabd2f347 100644
--- a/app/models/line_control/route.rb
+++ b/app/models/line_control/route.rb
@@ -1,7 +1,6 @@
module LineControl
class Route < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-Line-1"
+ def self.default_code; "3-Line-1" end
end
-end \ No newline at end of file
+end
diff --git a/app/models/route_control/duplicates.rb b/app/models/route_control/duplicates.rb
index fb9c34e0a..99e3b3aa8 100644
--- a/app/models/route_control/duplicates.rb
+++ b/app/models/route_control/duplicates.rb
@@ -1,7 +1,6 @@
module RouteControl
class Duplicates < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-Route-4"
+ def self.default_code; "3-Route-4" end
end
end
diff --git a/app/models/route_control/journey_pattern.rb b/app/models/route_control/journey_pattern.rb
index 08f603d8f..63cec2a41 100644
--- a/app/models/route_control/journey_pattern.rb
+++ b/app/models/route_control/journey_pattern.rb
@@ -1,7 +1,6 @@
module RouteControl
class JourneyPattern < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-Route-3"
+ def self.default_code; "3-Route-3" end
end
-end \ No newline at end of file
+end
diff --git a/app/models/route_control/minimum_length.rb b/app/models/route_control/minimum_length.rb
index f42b88748..56becfb2b 100644
--- a/app/models/route_control/minimum_length.rb
+++ b/app/models/route_control/minimum_length.rb
@@ -1,7 +1,6 @@
module RouteControl
class MinimumLength < ComplianceControl
- @@default_criticity = :error
- @@default_code = "3-Route-6"
+ def self.default_code; "3-Route-6" end
end
end
diff --git a/app/models/route_control/omnibus_journey_pattern.rb b/app/models/route_control/omnibus_journey_pattern.rb
index 3b9f6d06f..af3004ad7 100644
--- a/app/models/route_control/omnibus_journey_pattern.rb
+++ b/app/models/route_control/omnibus_journey_pattern.rb
@@ -1,7 +1,6 @@
module RouteControl
class OmnibusJourneyPattern < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-Route-9"
+ def self.default_code; "3-Route-9" end
end
end
diff --git a/app/models/route_control/opposite_route.rb b/app/models/route_control/opposite_route.rb
index e91b081e2..0148087ca 100644
--- a/app/models/route_control/opposite_route.rb
+++ b/app/models/route_control/opposite_route.rb
@@ -1,7 +1,6 @@
module RouteControl
class OppositeRoute < ComplianceControl
- @@default_criticity = :error
- @@default_code = "3-Route-2"
+ def self.default_code; "3-Route-2" end
end
end
diff --git a/app/models/route_control/opposite_route_terminus.rb b/app/models/route_control/opposite_route_terminus.rb
index fd62b7684..e12690d48 100644
--- a/app/models/route_control/opposite_route_terminus.rb
+++ b/app/models/route_control/opposite_route_terminus.rb
@@ -1,7 +1,6 @@
module RouteControl
class OppositeRouteTerminus < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-Route-5"
+ def self.default_code; "3-Route-5" end
end
-end \ No newline at end of file
+end
diff --git a/app/models/route_control/speed.rb b/app/models/route_control/speed.rb
index 0a2b6ac76..d5798d153 100644
--- a/app/models/route_control/speed.rb
+++ b/app/models/route_control/speed.rb
@@ -1,9 +1,8 @@
-module VehicleJourneyControl
+module RouteControl
class Speed < ComplianceControl
hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
- @@default_criticity = :warning
- @@default_code = "3-VehicleJourney-2"
+ def self.default_code; "3-VehicleJourney-2" end
end
end
diff --git a/app/models/route_control/stop_points_in_journey_pattern.rb b/app/models/route_control/stop_points_in_journey_pattern.rb
index dced6c005..400bef5ef 100644
--- a/app/models/route_control/stop_points_in_journey_pattern.rb
+++ b/app/models/route_control/stop_points_in_journey_pattern.rb
@@ -1,7 +1,6 @@
module RouteControl
- class StopPointInJourneyPattern < ComplianceControl
+ class StopPointsInJourneyPattern < ComplianceControl
- @@default_criticity = :error
- @@default_code = "3-Route-6"
+ def self.default_code; "3-Route-6" end
end
end
diff --git a/app/models/route_control/time_table.rb b/app/models/route_control/time_table.rb
index 5d0f21b40..069cd0a9e 100644
--- a/app/models/route_control/time_table.rb
+++ b/app/models/route_control/time_table.rb
@@ -1,7 +1,6 @@
-module VehicleJourneyControl
+module RouteControl
class TimeTable < ComplianceControl
- @@default_criticity = :error
- @@default_code = "3-VehicleJourney-4"
+ def self.default_code; "3-VehicleJourney-4" end
end
end
diff --git a/app/models/route_control/unactivated_stop_points.rb b/app/models/route_control/unactivated_stop_points.rb
index dee846cbb..a903fff53 100644
--- a/app/models/route_control/unactivated_stop_points.rb
+++ b/app/models/route_control/unactivated_stop_points.rb
@@ -1,7 +1,6 @@
module RouteControl
- class UnactivatedStopPoint < ComplianceControl
+ class UnactivatedStopPoints < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-Route-10"
+ def self.default_code; "3-Route-10" end
end
end
diff --git a/app/models/route_control/vehicle_journey_at_stops.rb b/app/models/route_control/vehicle_journey_at_stops.rb
index 149282fe6..7c376a2da 100644
--- a/app/models/route_control/vehicle_journey_at_stops.rb
+++ b/app/models/route_control/vehicle_journey_at_stops.rb
@@ -1,7 +1,6 @@
-module VehicleJourneyControl
+module RouteControl
class VehicleJourneyAtStops < ComplianceControl
- @@default_criticity = :error
- @@default_code = "3-VehicleJourney-5"
+ def self.default_code; "3-VehicleJourney-5" end
end
end
diff --git a/app/models/route_control/zdl_stop_area.rb b/app/models/route_control/zdl_stop_area.rb
index 088a1d2f2..2efd892df 100644
--- a/app/models/route_control/zdl_stop_area.rb
+++ b/app/models/route_control/zdl_stop_area.rb
@@ -1,7 +1,6 @@
module RouteControl
class ZDLStopArea < ComplianceControl
- @@default_criticity = :warning
- @@default_code = "3-Route-1"
+ def self.default_code; "3-Route-1" end
end
end
diff --git a/app/models/routing_constaint_zone_control/maximum_length.rb b/app/models/routing_constaint_zone_control/maximum_length.rb
deleted file mode 100644
index 4d289de63..000000000
--- a/app/models/routing_constaint_zone_control/maximum_length.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module RoutingConstaintZoneControl
- class MaximumLength < ComplianceControl
-
- @@default_criticity = :warning
- @@default_code = "3-ITL-2"
- end
-end \ No newline at end of file
diff --git a/app/models/routing_constaint_zone_control/minimum_length.rb b/app/models/routing_constaint_zone_control/minimum_length.rb
deleted file mode 100644
index 28f0791a7..000000000
--- a/app/models/routing_constaint_zone_control/minimum_length.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module RoutingConstaintZoneControl
- class MinimumLength < ComplianceControl
-
- @@default_criticity = :warning
- @@default_code = "3-ITL-3"
- end
-end \ No newline at end of file
diff --git a/app/models/routing_constaint_zone_control/unactivated_stop_point.rb b/app/models/routing_constaint_zone_control/unactivated_stop_point.rb
deleted file mode 100644
index fe5381a34..000000000
--- a/app/models/routing_constaint_zone_control/unactivated_stop_point.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module RoutingConstaintZoneControl
- class UnactivatedStopPoint < ComplianceControl
-
- @@default_criticity = :warning
- @@default_code = "3-ITL-1"
- end
-end
diff --git a/app/models/routing_constraint_zone_control/maximum_length.rb b/app/models/routing_constraint_zone_control/maximum_length.rb
new file mode 100644
index 000000000..6b726e38c
--- /dev/null
+++ b/app/models/routing_constraint_zone_control/maximum_length.rb
@@ -0,0 +1,6 @@
+module RoutingConstraintZoneControl
+ class MaximumLength < ComplianceControl
+
+ def self.default_code; "3-ITL-2" end
+ end
+end
diff --git a/app/models/routing_constraint_zone_control/minimum_length.rb b/app/models/routing_constraint_zone_control/minimum_length.rb
new file mode 100644
index 000000000..38f583bc5
--- /dev/null
+++ b/app/models/routing_constraint_zone_control/minimum_length.rb
@@ -0,0 +1,6 @@
+module RoutingConstraintZoneControl
+ class MinimumLength < ComplianceControl
+
+ def self.default_code; "3-ITL-3" end
+ end
+end
diff --git a/app/models/routing_constraint_zone_control/unactivated_stop_point.rb b/app/models/routing_constraint_zone_control/unactivated_stop_point.rb
new file mode 100644
index 000000000..c03bb2324
--- /dev/null
+++ b/app/models/routing_constraint_zone_control/unactivated_stop_point.rb
@@ -0,0 +1,6 @@
+module RoutingConstraintZoneControl
+ class UnactivatedStopPoint < ComplianceControl
+
+ def self.default_code; "3-ITL-1" end
+ end
+end
diff --git a/app/models/vechicle_journey_control/waiting_time.rb b/app/models/vechicle_journey_control/waiting_time.rb
deleted file mode 100644
index cbffa5526..000000000
--- a/app/models/vechicle_journey_control/waiting_time.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module VehicleJourneyControl
- class WatingTime < ComplianceControl
-
- @@default_criticity = :warning
- @@default_code = "3-VehicleJourney-1"
- end
-end
diff --git a/app/models/vechicle_journey_control/delta.rb b/app/models/vehicle_journey_control/delta.rb
index d77eff48a..797072fdd 100644
--- a/app/models/vechicle_journey_control/delta.rb
+++ b/app/models/vehicle_journey_control/delta.rb
@@ -3,7 +3,6 @@ module VehicleJourneyControl
hstore_accessor :control_attributes, delta: :integer
- @@default_criticity = :warning
- @@default_code = "3-VehicleJourney-3"
+ def self.default_code; "3-VehicleJourney-3" end
end
end
diff --git a/app/models/vehicle_journey_control/waiting_time.rb b/app/models/vehicle_journey_control/waiting_time.rb
new file mode 100644
index 000000000..614f401bb
--- /dev/null
+++ b/app/models/vehicle_journey_control/waiting_time.rb
@@ -0,0 +1,6 @@
+module VehicleJourneyControl
+ class WaitingTime < ComplianceControl
+
+ def self.default_code; "3-VehicleJourney-1" end
+ end
+end