Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 41 lines (33 sloc) 1.174 kB
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored
1
a2637e9 @wycats Try to build a new AC::Base on top of AbstractController
wycats authored
2 module ActionController
ca36326 @tilsammans cleanup of ActionController::Metal inline documentation
tilsammans authored
3 # Adds the ability to prevent public methods on a controller to be called as actions.
a2637e9 @wycats Try to build a new AC::Base on top of AbstractController
wycats authored
4 module HideActions
4e50a35 @josh Break up DependencyModule's dual function of providing a "depend_on" …
josh authored
5 extend ActiveSupport::Concern
00a9d4b Merge branch 'master' into wip_abstract_controller
Yehuda Katz + Carl Lerche authored
6
af40fa6 @josh Prefer "included" language over "setup"
josh authored
7 included do
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored
8 class_attribute :hidden_actions
b67ec8b @josevalim class_attribute is not a direct replacement of class_inheritable_*.
josevalim authored
9 self.hidden_actions = Set.new.freeze
a2637e9 @wycats Try to build a new AC::Base on top of AbstractController
wycats authored
10 end
af40fa6 @josh Prefer "included" language over "setup"
josh authored
11
82a10ce Removed unnecessary code
Yehuda Katz + Carl Lerche authored
12 private
de20324 @josh Revert "Revert "Whitespace!""
josh authored
13
47ff57f Document and clean up HideActions and Http
Yehuda Katz + Carl Lerche authored
14 # Overrides AbstractController::Base#action_method? to return false if the
15 # action name is in the list of hidden actions.
ac956c4 Update AP to start locking down a public API. This work is parallel t…
Yehuda Katz authored
16 def method_for_action(action_name)
17 self.class.visible_action?(action_name) && super
82a10ce Removed unnecessary code
Yehuda Katz + Carl Lerche authored
18 end
de20324 @josh Revert "Revert "Whitespace!""
josh authored
19
82a10ce Removed unnecessary code
Yehuda Katz + Carl Lerche authored
20 module ClassMethods
47ff57f Document and clean up HideActions and Http
Yehuda Katz + Carl Lerche authored
21 # Sets all of the actions passed in as hidden actions.
22 #
23 # ==== Parameters
ca36326 @tilsammans cleanup of ActionController::Metal inline documentation
tilsammans authored
24 # * <tt>args</tt> - A list of actions
82a10ce Removed unnecessary code
Yehuda Katz + Carl Lerche authored
25 def hide_action(*args)
b67ec8b @josevalim class_attribute is not a direct replacement of class_inheritable_*.
josevalim authored
26 self.hidden_actions = hidden_actions.dup.merge(args.map(&:to_s)).freeze
82a10ce Removed unnecessary code
Yehuda Katz + Carl Lerche authored
27 end
de20324 @josh Revert "Revert "Whitespace!""
josh authored
28
4bf516e @wycats More perf work:
wycats authored
29 def visible_action?(action_name)
0dfa6cb @gufo Fix broken ActionController#action_missing
gufo authored
30 not hidden_actions.include?(action_name)
4bf516e @wycats More perf work:
wycats authored
31 end
32
47ff57f Document and clean up HideActions and Http
Yehuda Katz + Carl Lerche authored
33 # Overrides AbstractController::Base#action_methods to remove any methods
34 # that are listed as hidden methods.
82a10ce Removed unnecessary code
Yehuda Katz + Carl Lerche authored
35 def action_methods
7cc5bf5 @thedarkone There is already a Set of non-hidden action_names lying around.
thedarkone authored
36 @action_methods ||= Set.new(super.reject { |name| hidden_actions.include?(name) }).freeze
de20324 @josh Revert "Revert "Whitespace!""
josh authored
37 end
82a10ce Removed unnecessary code
Yehuda Katz + Carl Lerche authored
38 end
a2637e9 @wycats Try to build a new AC::Base on top of AbstractController
wycats authored
39 end
de20324 @josh Revert "Revert "Whitespace!""
josh authored
40 end
Something went wrong with that request. Please try again.