<commit_before>class Aggregate::Attribute::String < Aggregate::Attribute::Builtin

  def self.available_options
    Aggregate::Attribute::Builtin.available_options + [
      :size, # The maximum length of the string
      :encrypted, # Whether or not we need to encrypt a field
    ]
  end

  def load(value)
    secret_key = nil # TODO set secret key in the config
    iv = nil # TODO set this in the config also

    :encrypted ? Encryptor.decrypt(value: value, key: secret_key, iv: iv) : value.to_s
  end

  def encrypt(value)
    secret_key = nil # TODO set secret key in the config
    iv = nil # TODO set this in the config also

    Encryptor.encrypt(value: value, key: secret_key, iv: iv)
  end

  def store(value)
    :encrypted ? encrypt(value) : value
  end

  def assign(value)
    value.to_s
  end

  def validation_errors(value)
    super + [
      ("#{value.class} is too long (maximum is #{options[:size]} characters)" if !options[:size].nil? && value.to_s.size > options[:size])
    ].compact
  end
end<commit_msg>STORY-5115 mixed up symbols - should be options<commit_after>class Aggregate::Attribute::String < Aggregate::Attribute::Builtin

  def self.available_options
    Aggregate::Attribute::Builtin.available_options + [
      :size, # The maximum length of the string
      :encrypted, # Whether or not we need to encrypt a field
    ]
  end

  def load(value)
    secret_key = nil # TODO set secret key in the config
    iv = nil # TODO set this in the config also

    options[:encrypted] ? Encryptor.decrypt(value: value, key: secret_key, iv: iv) : value.to_s
  end

  def encrypt(value)
    secret_key = nil # TODO set secret key in the config
    iv = nil # TODO set this in the config also

    Encryptor.encrypt(value: value, key: secret_key, iv: iv)
  end

  def store(value)
    options[:encrypted] ? encrypt(value) : value
  end

  def assign(value)
    value.to_s
  end

  def validation_errors(value)
    super + [
      ("#{value.class} is too long (maximum is #{options[:size]} characters)" if !options[:size].nil? && value.to_s.size > options[:size])
    ].compact
  end
end
{'fraction_non_alphanumeric': 0.1021759697256386, 'fraction_numerical': 0.001892147587511826, 'mean_word_length': 3.3518518518518516, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7568227', 'n_tokens_mistral': 682, 'n_tokens_neox': 653, 'n_words': 221}