<commit_before>module Lolita
  module Controllers
    module RailsHelpers
      extend ActiveSupport::Concern
      include Lolita::Controllers::InternalHelpers
      included do
        if self.ancestors.include?(ActionController::Base)
          helpers = %w(resource resource_name use_mapping
                       resource_class lolita_mapping show_response current_form current_form=)
          hide_action *helpers

          helper_method *helpers
          prepend_before_filter :is_lolita_resource?
          prepend_around_filter :switch_locale
        end
      end

      # Return instance variable named as resource
      # For 'posts' instance variable will be @posts


      protected

      def notice(msg, options = {})
        lolita_head_msg(msg,"Lolita-Notice",options)
      end

      def alert(msg,options = {})
        lolita_head_msg(msg,"Lolita-Alert",options)
      end

      def error(msg, options = {})
        lolita_head_msg(msg,"Lolita-Error",options)
      end

      def lolita_head_msg(msg,key,options ={})
        msg = Base64.encode64(msg).gsub("\n","")
        response.headers[key] = msg
        if options[:return]
          {key => msg}
        end
      end

      def resource_attributes
        fix_attributes(params[resource_name] || {})
      end

      def resource_with_attributes(current_resource,attributes={})
        attributes||=resource_attributes
        attributes.each{|key,value|
          current_resource.send(:"#{key}=",value)
        }
        current_resource
      end

      def get_resource(id=nil)
        self.resource = resource_class.lolita.dbi.find_by_id(id || params[:id])
        raise Lolita::RecordNotFound unless self.resource
      end

      def build_resource(attributes=nil)
        self.run(:before_build_resource)
        attributes||=resource_attributes
        self.resource=resource_with_attributes(resource_class.new,attributes)
        self.run(:after_build_resource)
      end

      def nested_list?<commit_msg>fixed strong params<commit_after>module Lolita
  module Controllers
    module RailsHelpers
      extend ActiveSupport::Concern
      include Lolita::Controllers::InternalHelpers
      included do
        if self.ancestors.include?(ActionController::Base)
          helpers = %w(resource resource_name use_mapping
                       resource_class lolita_mapping show_response current_form current_form=)
          hide_action *helpers

          helper_method *helpers
          prepend_before_filter :is_lolita_resource?
          prepend_around_filter :switch_locale
        end
      end

      # Return instance variable named as resource
      # For 'posts' instance variable will be @posts


      protected

      def notice(msg, options = {})
        lolita_head_msg(msg,"Lolita-Notice",options)
      end

      def alert(msg,options = {})
        lolita_head_msg(msg,"Lolita-Alert",options)
      end

      def error(msg, options = {})
        lolita_head_msg(msg,"Lolita-Error",options)
      end

      def lolita_head_msg(msg,key,options ={})
        msg = Base64.encode64(msg).gsub("\n","")
        response.headers[key] = msg
        if options[:return]
          {key => msg}
        end
      end

      def resource_attributes
        fix_attributes(params[resource_name] || {})
      end

      def resource_with_attributes(current_resource,attributes={})
        attributes ||= ActionController::Parameters.new(resource_attributes)
        attributes.permit!
        current_resource.attributes = attributes
        current_resource
      end

      def get_resource(id=nil)
        self.resource = resource_class.lolita.dbi.find_by_id(id || params[:id])
        raise Lolita::RecordNotFound unless self.resource
      end

      def build_resource(attributes=nil)
        self.run(:before_build_resource)
        attributes||=resource_attributes
        self.resource=resource_with_attributes(resource_class.new,attributes)
        self.run(:after_build_resource)
      end

      def nested_list?
{'fraction_non_alphanumeric': 0.08445106805762544, 'fraction_numerical': 0.001987083954297069, 'mean_word_length': 2.631199278629396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '658537', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1116, 'n_words': 209}