<commit_before>module ActionController
  module Resources
    class Resource
      attr_reader :path_segment, :actions_as, :resources_as, :namespaces_as

      def initialize(entities, options)
        @plural   ||= entities
        @singular ||= options[:singular] || plural.to_s.singularize

        @resources_as  = options.delete(:resources_as) || {}
        @actions_as    = options.delete(:actions_as) || {}
        @namespaces_as = options.delete(:namespaces_as) || {}
        
        @path_segment = options.delete(:as) || @resources_as[entities] || @plural

        @options = options

        arrange_actions
        add_default_actions
        set_prefixes
      end
      
      def path
        @path ||= "#{path_prefix}/#{path_segment}"
      end

      def new_path
        action_new = @actions_as[:new] || 'new'
        @new_path ||= "#{path}/#{action_new}"
      end
      
      def set_prefixes
        @path_prefix = change_namespace(options.delete(:path_prefix))
        @name_prefix = options.delete(:name_prefix)
      end
      
      def change_namespace(prefix)
        if prefix && @namespaces_as.has_key?(prefix)
          @namespaces_as[prefix].to_sym
        else
          prefix
        end
      end
    end

    def map_resource(entities, options = {}, &block)
      options.merge!(:actions_as => @actions_as, :resources_as => @resources_as, :namespaces_as => @namespaces_as)
      resource = Resource.new(entities, options)
      
      with_options :controller => resource.controller do |map|
        map_collection_actions(map, resource)
        map_default_collection_actions(map, resource)
        map_new_actions(map, resource)
        map_member_actions(map, resource)

        map_associations(resource, options)

        if block_given?
          with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, :namespace => options[:namespace], &block)
        end
      end
    end<commit_msg>Adding the option actions_as in map.resources to customize the actions of the route by an individual.<commit_after>module ActionController
  module Resources
    class Resource
      attr_reader :path_segment, :actions_as, :resources_as, :namespaces_as

      def initialize(entities, options)
        @plural   ||= entities
        @singular ||= options[:singular] || plural.to_s.singularize

        @resources_as  = options.delete(:resources_as) || {}
        @actions_as    = options.delete(:actions_as) || {}
        @namespaces_as = options.delete(:namespaces_as) || {}
        
        @path_segment = options.delete(:as) || @resources_as[entities] || @plural

        @options = options

        arrange_actions
        add_default_actions
        set_prefixes
      end
      
      def path
        @path ||= "#{path_prefix}/#{path_segment}"
      end

      def new_path
        action_new = @actions_as[:new] || 'new'
        @new_path ||= "#{path}/#{action_new}"
      end
      
      def set_prefixes
        @path_prefix = change_namespace(options.delete(:path_prefix))
        @name_prefix = options.delete(:name_prefix)
      end
      
      def change_namespace(prefix)
        if prefix && @namespaces_as.has_key?(prefix)
          @namespaces_as[prefix].to_sym
        else
          prefix
        end
      end
    end

    def map_resource(entities, options = {}, &block)
      @actions_as ||= {}
      actions_as = options.has_key?(:actions_as) ? @actions_as.merge(options[:actions_as]) : @actions_as
      
      options.merge!(:actions_as => actions_as, :resources_as => @resources_as, :namespaces_as => @namespaces_as)
      
      resource = Resource.new(entities, options)
      
      with_options :controller => resource.controller do |map|
        map_collection_actions(map, resource)
        map_default_collection_actions(map, resource)
        map_new_actions(map, resource)
        map_member_actions(map, resource)

        map_associations(resource, options)

        if block_given?
          with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, :namespace => options[:namespace], &block)
        end
      end
    end
{'fraction_non_alphanumeric': 0.10517529215358931, 'fraction_numerical': 0.0, 'mean_word_length': 2.6660839160839163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1332379', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1209, 'n_words': 231}