aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2017-12-20 22:17:41 +0100
committerAlban Peignier2017-12-20 22:17:41 +0100
commitc683f940f274d9f9a9cbfb00e33c6f45a3526960 (patch)
treede17c3b082391b104b868b9f591dbdd3acf2187b
parent1baebfe532dc31ed45c9275fed77c8975dfa169d (diff)
downloadchouette-core-c683f940f274d9f9a9cbfb00e33c6f45a3526960.tar.bz2
Check feature in ReferentialDecorator by supporting 'partial' context (like an view spec). Refs #53375341-create-referential-vehiclejourneys-controller
-rw-r--r--app/decorators/referential_decorator.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/decorators/referential_decorator.rb b/app/decorators/referential_decorator.rb
index 72f4706fe..9ebb6f330 100644
--- a/app/decorators/referential_decorator.rb
+++ b/app/decorators/referential_decorator.rb
@@ -5,7 +5,7 @@ class ReferentialDecorator < Draper::Decorator
policy = h.policy(object)
links = []
- if h.has_feature?(:referential_vehicle_journeys)
+ if has_feature?(:referential_vehicle_journeys)
links << Link.new(
content: h.t('referential_vehicle_journeys.index.title'),
href: h.referential_vehicle_journeys_path(object)
@@ -70,4 +70,12 @@ class ReferentialDecorator < Draper::Decorator
links
end
+
+ private
+
+ # TODO move to a base Decorator (ApplicationDecorator)
+ def has_feature?(*feature)
+ h.has_feature?(*features) rescue false
+ end
+
end