serializable
Serializable
Unified serialization/deserialization interface.
Installation
-
Add the dependency to your
shard.yml
:dependencies: serializable: github: jgaskins/serializable
-
Run
shards install
Usage
In your serializable objects, include the Serializable::Object
mixin:
require "serializable/object"
struct Post
include Serializable::Object
getter id : UUID
getter title : String
getter body : String
getter author_id : UUID
getter author_display_name : String
getter published_at : Time
end
Make sure you require any of the adapters needed for the serialization formats you are using:
require "serializable/json"
require "serializable/msgpack"
require "serializable/db"
These adapters add the from_#{format}
/ to_#{format}
methods. If you only need JSON, you can simply require the serializable/json
adapter.
If you need additional serialization formats, please open an issue or a PR.
Development
This is still early days for this shard. The development process hasn't been ironed out yet.
Contributing
- Fork it (https://github.com/jgaskins/serializable/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Jamie Gaskins - creator and maintainer
Repository
serializable
Owner
Statistic
- 2
- 0
- 0
- 0
- 3
- 3 months ago
- August 24, 2024
License
MIT License
Links
Synced at
Sun, 22 Dec 2024 05:26:09 GMT
Languages