<commit_before># SimpleSerializer

Simple framelet for serializing/deserializing objects to hashes.

API compatible with ActiveModel::Serializer but without all the complexity
and dependence on ActiveModel

# Serializer Usage

```
class SomeSerializer < SimpleSerializer::Serializer
  attributes :id, :name, :category_id, :errors

  def category_id
    object.category.try(:id)
  end

  def errors
    ActiveModelErrorsSerializer.serialize_errors(object.errors, true) if object.errors.any?
  end
end
```

Use it:

```
SomeSerializer.serialize(object)
SomeSerializer.new(object).serialize

SomeSerializer.serialize_array([object])
```

# Deserializer Usage

```
class SomeDeserializer < SimpleSerializer::Deserializer
  data_attributes :site_id, :name, :category_id, :integration_key

  def integration_key(old_integration_key)
    "XX#{@data[:other_attr]}XX#{old_integration_key}XX"
  end

  def set_category_id(category_id)
    object.category = InventoryStatusCategory.from_id(category_id)
  end
end
```

Use it:

```
SomeDeserializer.deserialize(object, data)
SomeDeserializer.new(object, data).deserialize

SomeDeserializer.deserialize_array([object1, object2, ...], [data1, data2, ...])
```<commit_msg>Updates README to current api.<commit_after># SimpleSerializer

Simple framelet for serializing/deserializing objects to hashes.

API compatible with ActiveModel::Serializer but without all the complexity
and NO ROOT KEYS!

# Serializer Usage

```
class SomeSerializer < SimpleSerializer::Serializer
  hash_attributes :id, :name, :category_id, :errors

  def category_id
    object.category.try(:id)
  end

  def errors
    ActiveModelErrorsSerializer.serialize_errors(object.errors, true) if object.errors.any?
  end
end
```

Use it:

```
SomeSerializer.serialize(object)
SomeSerializer.new(object).serialize

SomeSerializer.serialize_array([object])
```

# Deserializer Usage

```
class SomeDeserializer < SimpleSerializer::Deserializer
  object_attributes :site_id, :name, :category_id, :integration_key

  def integration_key(old_integration_key)
    "XX#{@data[:other_attr]}XX#{old_integration_key}XX"
  end

  def set_site_id
    object.site_id = 99
  end
end
```

Use it:

```
SomeDeserializer.deserialize(object, data)
SomeDeserializer.new(object, data).deserialize

SomeDeserializer.deserialize_array([object1, object2, ...], [data1, data2, ...])
```
{'fraction_non_alphanumeric': 0.10777683854606931, 'fraction_numerical': 0.00422654268808115, 'mean_word_length': 5.900874635568513, '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': '30583', 'n_tokens_mistral': 750, 'n_tokens_neox': 722, 'n_words': 162}