Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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