<commit_before>require 'active_record/typed_store/column'
require 'active_record/typed_store/dsl'
require 'active_record/typed_store/typed_hash'

module ActiveRecord::TypedStore
  AR_VERSION = Gem::Version.new(ActiveRecord::VERSION::STRING)
  IS_AR_3_2 = AR_VERSION < Gem::Version.new('4.0')
  IS_AR_4_1 = AR_VERSION >= Gem::Version.new('4.1') && AR_VERSION < Gem::Version.new('4.2.0')
  IS_AR_4_2 = AR_VERSION >= Gem::Version.new('4.2.0')

  module Extension
    extend ActiveSupport::Concern

    included do
      class_attribute :typed_stores, instance_accessor: false
      class_attribute :typed_store_attributes, instance_accessor: false
    end

    module ClassMethods

      def typed_store(store_attribute, options={}, &block)
        dsl = DSL.new(options.fetch(:accessors, true), &block)

        unless options[:no_coder]
          coder = create_coder(store_attribute, dsl.columns).new(options[:coder])
          serialize store_attribute, coder
        end

        store_accessor(store_attribute, dsl.accessors)

        register_typed_store_columns(store_attribute, dsl.columns)
        super(store_attribute, dsl) if defined?(super)

        dsl.accessors.each { |c| define_store_attribute_queries(store_attribute, c) }

        dsl
      end

      def define_attribute_methods
        super
        define_typed_store_attribute_methods
      end

      def undefine_attribute_methods # :nodoc:
        super if @typed_store_attribute_methods_generated
        @typed_store_attribute_methods_generated = false
      end

      private<commit_msg>no serialization when coder: false<commit_after>require 'active_record/typed_store/column'
require 'active_record/typed_store/dsl'
require 'active_record/typed_store/typed_hash'

module ActiveRecord::TypedStore
  AR_VERSION = Gem::Version.new(ActiveRecord::VERSION::STRING)
  IS_AR_3_2 = AR_VERSION < Gem::Version.new('4.0')
  IS_AR_4_1 = AR_VERSION >= Gem::Version.new('4.1') && AR_VERSION < Gem::Version.new('4.2.0')
  IS_AR_4_2 = AR_VERSION >= Gem::Version.new('4.2.0')

  module Extension
    extend ActiveSupport::Concern

    included do
      class_attribute :typed_stores, instance_accessor: false
      class_attribute :typed_store_attributes, instance_accessor: false
    end

    module ClassMethods

      def typed_store(store_attribute, options={}, &block)
        dsl = DSL.new(options.fetch(:accessors, true), &block)

        unless options[:coder] == false
          coder = create_coder(store_attribute, dsl.columns).new(options[:coder])
          serialize store_attribute, coder
        end

        store_accessor(store_attribute, dsl.accessors)

        register_typed_store_columns(store_attribute, dsl.columns)
        super(store_attribute, dsl) if defined?(super)

        dsl.accessors.each { |c| define_store_attribute_queries(store_attribute, c) }

        dsl
      end

      def define_attribute_methods
        super
        define_typed_store_attribute_methods
      end

      def undefine_attribute_methods # :nodoc:
        super if @typed_store_attribute_methods_generated
        @typed_store_attribute_methods_generated = false
      end

      private
{'fraction_non_alphanumeric': 0.0914846470402026, 'fraction_numerical': 0.010129787907565685, 'mean_word_length': 3.709388971684054, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6122435', 'n_tokens_mistral': 1006, 'n_tokens_neox': 977, 'n_words': 172}