<commit_before>module ActsAsActiveAdminController
  extend ActiveSupport::Concern

  module ActionController
    def acts_as_active_admin_controller(element_lookup_key)
      @active_admin_resource_element_lookup_key = element_lookup_key
      include ::ActsAsActiveAdminController
    end
  end

  included do
    include ActiveAdmin::BaseController::Menu
    include ActiveAdmin::BaseController::Authorization

    helper ActiveAdmin::ViewHelpers
    helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user

    resource_key = @active_admin_resource_element_lookup_key.to_s
    self.send(:define_method, :active_admin_resource_element_key) { resource_key }

    resource_ivar = '@' + resource_key.singularize
    self.send(:define_method, :resource) { instance_variable_get(resource_ivar) }

    resource_path = "effective_orders.#{resource_key.singularize}_path"

    if resource_path == 'effective_orders.cart_path'
      self.send(:define_method, :resource_path) { |resource| effective_orders.cart_path }
    else
      self.send(:define_method, :resource_path) { |resource| public_send(resource_path, resource) }
    end

    helper_method :resource, :resource_path
  end

  module ClassMethods
  end

  def active_admin_namespace
    ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
  end

  def active_admin_config
    active_admin_namespace.resources[active_admin_resource_key]
  end

  def active_admin_resource_key
    @active_admin_resource_key ||= begin
      namespace = ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
      namespace.resources.keys.find { |resource| resource.element == active_admin_resource_element_key }
    end
  end

  def current_active_admin_user
    send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
  end

end
<commit_msg>work with activeadmin 1.0.0.pre2<commit_after>module ActsAsActiveAdminController
  extend ActiveSupport::Concern

  module ActionController
    def acts_as_active_admin_controller(element_lookup_key)
      @active_admin_resource_element_lookup_key = element_lookup_key
      include ::ActsAsActiveAdminController
    end
  end

  included do
    include ActiveAdmin::BaseController::Menu
    include ActiveAdmin::BaseController::Authorization

    helper ActiveAdmin::ViewHelpers
    helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user, :current_active_admin_user?, :env

    resource_key = @active_admin_resource_element_lookup_key.to_s
    self.send(:define_method, :active_admin_resource_element_key) { resource_key }

    resource_ivar = '@' + resource_key.singularize
    self.send(:define_method, :resource) { instance_variable_get(resource_ivar) }

    resource_path = "effective_orders.#{resource_key.singularize}_path"

    if resource_path == 'effective_orders.cart_path'
      self.send(:define_method, :resource_path) { |resource| effective_orders.cart_path }
    else
      self.send(:define_method, :resource_path) { |resource| public_send(resource_path, resource) }
    end

    helper_method :resource, :resource_path
  end

  module ClassMethods
  end

  def active_admin_namespace
    ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
  end

  def active_admin_config
    active_admin_namespace.resources[active_admin_resource_key]
  end

  def active_admin_resource_key
    @active_admin_resource_key ||= begin
      namespace = ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
      namespace.resources.keys.find { |resource| resource.element == active_admin_resource_element_key }
    end
  end

  # Calls the authentication method as defined in ActiveAdmin.authentication_method
  def authenticate_active_admin_user
    send(active_admin_namespace.authentication_method) if active_admin_namespace.authentication_method
  end

  def current_active_admin_user
    send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
  end

  def current_active_admin_user?
    !!current_active_admin_user
  end


end

{'fraction_non_alphanumeric': 0.06677836285303973, 'fraction_numerical': 0.0009573958831977022, 'mean_word_length': 5.5501567398119125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3106587', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1201, 'n_words': 199}