<commit_before>module Stateflow
  module Persistence
    module ActiveRecord
      extend ActiveSupport::Concern

      included do
        before_validation(:ensure_initial_state, :on => :create)
      end

      module ClassMethods
        def add_scope(state)
          scope state.name, where("#{machine.state_column}".to_sym => state.name.to_s)
        end
      end

      def load_from_persistence
        send machine.state_column.to_sym
      end

      def save_to_persistence(new_state, options = {})
        send("#{machine.state_column}=".to_sym, new_state)
        save if options[:save]<commit_msg>Fix ActiveRecord deprecation warning from old-school scope usage.<commit_after>module Stateflow
  module Persistence
    module ActiveRecord
      extend ActiveSupport::Concern

      included do
        before_validation(:ensure_initial_state, :on => :create)
      end

      module ClassMethods
        def add_scope(state)
          scope state.name, proc { where("#{machine.state_column}".to_sym => state.name.to_s) }
        end
      end

      def load_from_persistence
        send machine.state_column.to_sym
      end

      def save_to_persistence(new_state, options = {})
        send("#{machine.state_column}=".to_sym, new_state)
        save if options[:save]
{'fraction_non_alphanumeric': 0.08391608391608392, 'fraction_numerical': 0.0, 'mean_word_length': 2.7551020408163267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5313768', 'n_tokens_mistral': 367, 'n_tokens_neox': 359, 'n_words': 81}