<commit_before>module ActiveHash
  module Associations

    module ActiveRecordExtensions

      def belongs_to(name, scope = nil, **options)
        options = {:class_name => name.to_s.camelize }.merge(options)
        klass =
          begin
            options[:class_name].constantize
          rescue
            nil
          rescue LoadError
            nil
          end
        if klass && klass < ActiveHash::Base
          belongs_to_active_hash(name, options)
        else
          super
        end
      end

      def belongs_to_active_hash(association_id, options = {})
        options = {
          :class_name => association_id.to_s.camelize,
          :foreign_key => association_id.to_s.foreign_key,
          :shortcuts => []
        }.merge(options)
        # Define default primary_key with provided class_name if any
        options[:primary_key] ||= options[:class_name].constantize.primary_key
        options[:shortcuts] = [options[:shortcuts]] unless options[:shortcuts].kind_of?(Array)

        define_method(association_id) do
          options[:class_name].constantize.send("find_by_#{options[:primary_key]}", send(options[:foreign_key]))
        end

        define_method("#{association_id}=") do |new_value|
          send "#{options[:foreign_key]}=", new_value ? new_value.send(options[:primary_key]) : nil
        end

        options[:shortcuts].each do |shortcut|<commit_msg>Use double splat operator in belongs_to call to super<commit_after>module ActiveHash
  module Associations

    module ActiveRecordExtensions

      def belongs_to(name, scope = nil, **options)
        options = {:class_name => name.to_s.camelize }.merge(options)
        klass =
          begin
            options[:class_name].constantize
          rescue
            nil
          rescue LoadError
            nil
          end
        if klass && klass < ActiveHash::Base
          belongs_to_active_hash(name, options)
        else
          super(name, **options)
        end
      end

      def belongs_to_active_hash(association_id, options = {})
        options = {
          :class_name => association_id.to_s.camelize,
          :foreign_key => association_id.to_s.foreign_key,
          :shortcuts => []
        }.merge(options)
        # Define default primary_key with provided class_name if any
        options[:primary_key] ||= options[:class_name].constantize.primary_key
        options[:shortcuts] = [options[:shortcuts]] unless options[:shortcuts].kind_of?(Array)

        define_method(association_id) do
          options[:class_name].constantize.send("find_by_#{options[:primary_key]}", send(options[:foreign_key]))
        end

        define_method("#{association_id}=") do |new_value|
          send "#{options[:foreign_key]}=", new_value ? new_value.send(options[:primary_key]) : nil
        end

        options[:shortcuts].each do |shortcut|
{'fraction_non_alphanumeric': 0.10433275563258232, 'fraction_numerical': 0.0, 'mean_word_length': 2.5195121951219512, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5302714', 'n_tokens_mistral': 826, 'n_tokens_neox': 808, 'n_words': 158}