<commit_before>require "statable/version"

module Statable

  module ClassMethods

    # attr - attribute name
    # options - additional options
    def statable(attr, options = {})

      include Redis::Objects unless self.include?(Redis::Objects)

      callbacks = options[:callbacks] || {}
      scope = options[:scope] || self
      type = options[:type] || :counter
      conditions = options[:conditions] || {}

      root_class = self

      # setup redis-object attribute
      self.send type, attr

      # wire callbacks
      callbacks.each do |key, callback|
        scope.send key, ->(record) {
          if root_class.evaluate_conditions(record, conditions)
<commit_msg>changed -> to lambda for readability<commit_after>require "statable/version"

module Statable

  module ClassMethods

    # attr - attribute name
    # options - additional options
    def statable(attr, options = {})

      include Redis::Objects unless self.include?(Redis::Objects)

      callbacks = options[:callbacks] || {}
      scope = options[:scope] || self
      type = options[:type] || :counter
      conditions = options[:conditions] || {}

      root_class = self

      # setup redis-object attribute
      self.send type, attr

      # wire callbacks
      callbacks.each do |key, callback|
        scope.send key, lambda { |record|
          if root_class.evaluate_conditions(record, conditions)

{'fraction_non_alphanumeric': 0.10571428571428572, 'fraction_numerical': 0.0, 'mean_word_length': 2.8383561643835615, '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': '2305808', 'n_tokens_mistral': 383, 'n_tokens_neox': 370, 'n_words': 103}