aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/new_base/hide_actions.rb
blob: d1857a91690e0ac0b7a551de405f75dad66dd9b9 (plain) (blame)
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
26
27
28
29
30
31
32
33
module ActionController
  module HideActions
    extend ActiveSupport::DependencyModule

    included do
      extlib_inheritable_accessor :hidden_actions
      self.hidden_actions ||= Set.new
    end

    def action_methods() self.class.action_names end
    def action_names() action_methods end    
      
  private
  
    def respond_to_action?(action_name)
      !hidden_actions.include?(action_name) && (super || respond_to?(:method_missing))
    end
    
    module ClassMethods
      def hide_action(*args)
        args.each do |arg|
          self.hidden_actions << arg.to_s
        end
      end
      
      def action_methods
        @action_names ||= Set.new(super.reject {|name| self.hidden_actions.include?(name.to_s)})
      end

      def self.action_names() action_methods end
    end
  end
end