<commit_before>require 'rails_admin/abstract_model'

module RailsAdmin
  class ApplicationController < ::ApplicationController
    before_filter :_authenticate!
    before_filter :_authorize!
    before_filter :set_plugin_name

    helper_method :_current_user

    def get_model
      model_name = to_model_name(params[:model_name])
      @abstract_model = RailsAdmin::AbstractModel.new(model_name)
      @model_config = RailsAdmin.config(@abstract_model)
      not_found if @model_config.excluded?
      @properties = @abstract_model.properties
    end

    def to_model_name(param)
      parts = param.split("~")
      parts.map{|x| x == parts.last ? x.singularize.camelize : x.camelize}.join("::")
    end

    def get_object
      @object = @abstract_model.get(params[:id])
      not_found unless @object
    end

    private

    def _authenticate!
      instance_eval &RailsAdmin.authenticate_with
    end

    def _authorize!
      instance_eval &RailsAdmin.authorize_with
    end

    def _current_user
      instance_eval &RailsAdmin.current_user_method
    end

    def set_plugin_name
      @plugin_name = "RailsAdmin"
    end

    def not_found
      render :file => Rails.root.join('public', '404.html'), :layout => false, :status => 404
    end

    def rails_admin_controller?
      true
    end
  end
end
<commit_msg>Tell NewRelic RPM to ignore admin site<commit_after>require 'rails_admin/abstract_model'

module RailsAdmin
  class ApplicationController < ::ApplicationController
    newrelic_ignore if defined?(NewRelic)

    before_filter :_authenticate!
    before_filter :_authorize!
    before_filter :set_plugin_name

    helper_method :_current_user

    def get_model
      model_name = to_model_name(params[:model_name])
      @abstract_model = RailsAdmin::AbstractModel.new(model_name)
      @model_config = RailsAdmin.config(@abstract_model)
      not_found if @model_config.excluded?
      @properties = @abstract_model.properties
    end

    def to_model_name(param)
      parts = param.split("~")
      parts.map{|x| x == parts.last ? x.singularize.camelize : x.camelize}.join("::")
    end

    def get_object
      @object = @abstract_model.get(params[:id])
      not_found unless @object
    end

    private

    def _authenticate!
      instance_eval &RailsAdmin.authenticate_with
    end

    def _authorize!
      instance_eval &RailsAdmin.authorize_with
    end

    def _current_user
      instance_eval &RailsAdmin.current_user_method
    end

    def set_plugin_name
      @plugin_name = "RailsAdmin"
    end

    def not_found
      render :file => Rails.root.join('public', '404.html'), :layout => false, :status => 404
    end

    def rails_admin_controller?
      true
    end
  end
end

{'fraction_non_alphanumeric': 0.08442982456140351, 'fraction_numerical': 0.0043859649122807015, 'mean_word_length': 3.2302936630602783, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 9, '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': '4148776', 'n_tokens_mistral': 893, 'n_tokens_neox': 838, 'n_words': 179}