<commit_before>module TokenAction
  module Model
    extend ActiveSupport::Concern
    include TokenAction::TokenGenerator

    included do
      validates_presence_of :token, :kind

      # ActiveRecord, Mongoid, MongoMapper and DataMapper implement
      # `validates_uniqueness_of`. Sequel implements it in a plugin.
      #
      # @see http://sequel.rubyforge.org/rdoc-plugins/classes/Sequel/Plugins/ValidationClassMethods.html
      validates_uniqueness_of :token

      before_validation :set_token
    end

    # Performs the action.
    def perform
      kind.constantize.perform *args
    end

  private

    def set_token
      self.token ||= self.class.generate_token :token
    end
  end
end
<commit_msg>use ActiveSupport::Inflector explicitly<commit_after>module TokenAction
  module Model
    extend ActiveSupport::Concern
    include TokenAction::TokenGenerator

    included do
      validates_presence_of :token, :kind

      # ActiveRecord, Mongoid, MongoMapper and DataMapper implement
      # `validates_uniqueness_of`. Sequel implements it in a plugin.
      #
      # @see http://sequel.rubyforge.org/rdoc-plugins/classes/Sequel/Plugins/ValidationClassMethods.html
      validates_uniqueness_of :token

      before_validation :set_token
    end

    # Performs the action.
    def perform
      ActiveSupport::Inflector.constantize(kind).perform(*args)
    end

  private

    def set_token
      self.token ||= self.class.generate_token(:token)
    end
  end
end

{'fraction_non_alphanumeric': 0.06989247311827956, 'fraction_numerical': 0.0, 'mean_word_length': 3.1943661971830988, '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': '2625201', 'n_tokens_mistral': 443, 'n_tokens_neox': 424, 'n_words': 100}