<commit_before>module MinistryOfState
  extend ActiveSupport::Concern

  class InvalidState < Exception; end
  class NoInitialState < Exception; end
  class TransitionNotAllowed < Exception; end
  class InvalidStateColumn < Exception; end

  module ClassMethods
    class MosState
      def initialize(name, column, opts)
        @name, @column, @opts = name, column, opts
      end

      attr_reader :name, :column, :opts

      def initial?
        opts[:initial]
      end
    end

    class MosEvent
      def initialize(name, column, opts)
        @name, @column, @opts = name, column, opts
      end

      attr_reader :name, :column, :opts
    end

    # create a hash for states
    def prepare_mos_attributes
      unless self.respond_to?(:states)
        class_attribute :states
        class_attribute :events

        self.states = HashWithIndifferentAccess.new
        self.events = HashWithIndifferentAccess.new

        before_create :set_initial_states
        after_create  :run_initial_state_actions
      end
    end

    def get_initial_state_for(column)<commit_msg>pull out classes from ClassMethods module<commit_after>module MinistryOfState
  extend ActiveSupport::Concern

  class InvalidState < Exception; end
  class NoInitialState < Exception; end
  class TransitionNotAllowed < Exception; end
  class InvalidStateColumn < Exception; end

  class MosState
    def initialize(name, column, opts)
      @name, @column, @opts = name, column, opts
    end

    attr_reader :name, :column, :opts

    def initial?
      opts[:initial]
    end
  end

  class MosEvent
    def initialize(name, column, opts)
      @name, @column, @opts = name, column, opts
    end

    attr_reader :name, :column, :opts
  end

  module ClassMethods

    # create a hash for states
    def prepare_mos_attributes
      unless self.respond_to?(:states)
        class_attribute :states
        class_attribute :events

        self.states = HashWithIndifferentAccess.new
        self.events = HashWithIndifferentAccess.new

        before_create :set_initial_states
        after_create  :run_initial_state_actions
      end
    end

    def get_initial_state_for(column)
{'fraction_non_alphanumeric': 0.06350667280257709, 'fraction_numerical': 0.0, 'mean_word_length': 2.9455535390199636, 'pattern_counts': {'":': 0, '<': 11, '<?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': '2546636', 'n_tokens_mistral': 616, 'n_tokens_neox': 591, 'n_words': 178}