Skip to content

Commit c63dd5a

Browse files
authored
Release 1.3.0 (#113)
* Add docs for hash serialization * Bump version to 1.3.0
1 parent b0d38e5 commit c63dd5a

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

CHANGELOG.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# 1.3.0
2+
3+
## Added
4+
5+
* Hash serialization ([@stefkin][]) [#106](https://github.com/nesaulov/surrealist/pull/106)
6+
7+
## Fixed
8+
9+
* Conflict when root and object property share the same name ([@akxcv][]) [#99](https://github.com/nesaulov/surrealist/pull/99)
10+
* Precedence was given to object method instead of serializer one ([@gjhenrique][] & [@nesaulov][]) [#110](https://github.com/nesaulov/surrealist/pull/110) & [#111](https://github.com/nesaulov/surrealist/pull/111)
11+
112
# 1.2.0
213

314
## Added
@@ -102,4 +113,5 @@
102113
[@azhi]: https://github.com/azhi
103114
[@chrisatanasian]: https://github.com/chrisatanasian
104115
[@past-one]: https://github.com/past-one
105-
116+
[@stefkin]: https://github.com/stefkin
117+
[@gjhenrique]: https://github.com/gjhenrique

README.md

+20-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ to serialize nested objects and structures. [Introductory blogpost.](https://med
4040
* [Root](#root)
4141
* [Include namespaces](#include-namespaces)
4242
* [Configuration](#configuration)
43+
* [Hash serialization](#hash-serialization)
4344
* [Bool and Any](#bool-and-any)
4445
* [Type errors](#type-errors)
4546
* [Undefined methods in schema](#undefined-methods-in-schema)
@@ -687,7 +688,7 @@ withdraws.surrealize(include_namespaces: true, namespaces_nesting_level: 2)
687688

688689
There are two ways of setting default arguments for serialization,
689690
by passing a block to `Surrealist.configure`:
690-
```ruby
691+
``` ruby
691692
Surrealist.configure do |config|
692693
config.camelize = true
693694
config.namespaces_nesting_level = 2
@@ -700,13 +701,28 @@ And by passing a hash:
700701
These arguments will be applied to all calls of `#build_schema` and `#surrealize`.
701702
If these methods will be called with arguments, they will be merged with respect to explicitly passed ones:
702703

703-
```ruby
704+
``` ruby
704705
Surrealist.configure(camelize: true, include_root: true)
705706

706707
Something.new.surrealize(camelize: false)
707708
# will result in Something.new.surrealize(camelize: false, include_root: true)
708709
```
709710

711+
### Hash serialization
712+
713+
You can pass a hash to serializer and it will use the keys instead of methods.
714+
715+
``` ruby
716+
class HashSerializer < Surrealist::Serializer
717+
json_schema { { string: String, int: Integer } }
718+
end
719+
720+
HashSerializer.new(string: 'string', int: 4).surrealize
721+
# => '{ "string": "string", "int": 4}'
722+
723+
HashSerializer.new(string: 'string', int: 'not int').surrealize
724+
# => Surrealist::InvalidTypeError: Wrong type for key `int`. Expected Integer, got String.
725+
```
710726

711727
### Bool and Any
712728
If you have a parameter that is of boolean type, or if you don't care about the type, you
@@ -769,7 +785,8 @@ type check will be passed. If you want to be strict about `nil`s consider using
769785

770786
## Roadmap
771787
Here is a list of features that are not implemented yet (contributions are welcome):
772-
* Memoization/caching
788+
* Automatic endpoint documentation
789+
* API for validating (contracts) without actually serializing to JSON (maybe with deserialization from JSON)
773790

774791
## Contributing
775792
Bug reports and pull requests are welcome on GitHub at https://github.com/nesaulov/surrealist.

lib/surrealist/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
module Surrealist
44
# Defines the version of Surrealist
5-
VERSION = '1.2.0'.freeze
5+
VERSION = '1.3.0'.freeze
66
end

0 commit comments

Comments
 (0)