<commit_before>unless CANVAS_RAILS2  
  Switchman::Shard.class_eval do
    class << self
      alias :birth :default
    end

    self.primary_key = "id"
    serialize :settings, Hash

    before_save :encrypt_settings

    def settings
      s = super
      if s.nil?
        self.settings = s = {}
      elsif !s.is_a?(Hash)
        s = s.unserialize
      end

      salt = s.delete(:encryption_key_salt)
      secret = s.delete(:encryption_key_enc)
      if secret || salt
        if secret && salt
          s[:encryption_key] = Canvas::Security.decrypt_password(secret, salt, 'shard_encryption_key')
        end
        self.settings = s
      end

      s
    end

    def encrypt_settings
      s = self.settings.dup
      if encryption_key = s.delete(:encryption_key)
        secret, salt = Canvas::Security.encrypt_password(encryption_key, 'shard_encryption_key')
        s[:encryption_key_enc] = secret
        s[:encryption_key_salt] = salt
      end
      if s != self.settings
        self.settings = s
      end
      s
    end
  end

  ::Shard = Switchman::Shard

  Switchman::DefaultShard.class_eval do
    attr_writer :settings

    def settings
      {}
    end
  end
end<commit_msg>set DatabaseServer to Switchman::DatabaseServer in rails 3<commit_after>unless CANVAS_RAILS2  
  Switchman::Shard.class_eval do
    class << self
      alias :birth :default
    end

    self.primary_key = "id"
    serialize :settings, Hash

    before_save :encrypt_settings

    def settings
      s = super
      if s.nil?
        self.settings = s = {}
      elsif !s.is_a?(Hash)
        s = s.unserialize
      end

      salt = s.delete(:encryption_key_salt)
      secret = s.delete(:encryption_key_enc)
      if secret || salt
        if secret && salt
          s[:encryption_key] = Canvas::Security.decrypt_password(secret, salt, 'shard_encryption_key')
        end
        self.settings = s
      end

      s
    end

    def encrypt_settings
      s = self.settings.dup
      if encryption_key = s.delete(:encryption_key)
        secret, salt = Canvas::Security.encrypt_password(encryption_key, 'shard_encryption_key')
        s[:encryption_key_enc] = secret
        s[:encryption_key_salt] = salt
      end
      if s != self.settings
        self.settings = s
      end
      s
    end
  end

  ::Shard = Switchman::Shard
  ::DatabaseServer = Switchman::DatabaseServer

  Switchman::DefaultShard.class_eval do
    attr_writer :settings

    def settings
      {}
    end
  end
end

{'fraction_non_alphanumeric': 0.08530236283540249, 'fraction_numerical': 0.0012014417300760913, 'mean_word_length': 2.256844850065189, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3723473', 'n_tokens_mistral': 814, 'n_tokens_neox': 783, 'n_words': 179}