fried-schema 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/lib/fried/schema/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a615c7ea19d0244ce08a18d86d25440eaf83e189
|
4
|
+
data.tar.gz: 371e26fae5f1dcd7a5b4643174a95fe3e3059013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1e686ac6471cd4b1017c3854aa90dfd614b08e61b20e2e8b81d4fc7b09ffdf26d4b911da6c4853f6ead0a16f742ec8965fd3deb7136a603db6e6b337dafa172
|
7
|
+
data.tar.gz: a28e79ee31e986c34e427552766382828f028042e52d543a2557d290f2431c2d1f2be7e33ab995841265eb6366156d9b75eeae79a0deb212fe88d21e0823f552
|
data/README.md
CHANGED
@@ -71,6 +71,36 @@ person.age # => 123
|
|
71
71
|
person.to_h # => { name: "John", born_at: 2017-11-24 00:55:50 -0800, age: 123 }
|
72
72
|
```
|
73
73
|
|
74
|
+
### Fried::Typings integration
|
75
|
+
|
76
|
+
The gem integrates with [fried-typings][fried-typings-link], you can use
|
77
|
+
those type as checks:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
class Person
|
81
|
+
include Fried::Typings
|
82
|
+
include Fried::Schema::DataEntity
|
83
|
+
|
84
|
+
attribute :hobbies, ArrayOf[String], default: []
|
85
|
+
attribute :something, OneOf[String, Numeric]
|
86
|
+
end
|
87
|
+
|
88
|
+
person = Person.build(hobbies: ["foo", "bar"])
|
89
|
+
|
90
|
+
person.hobbies # => ["foo", "bar"]
|
91
|
+
person.hobbies = [123, "foo"] # => raises TypeError
|
92
|
+
person.hobbies = []
|
93
|
+
person.hobbies # => []
|
94
|
+
person.hobbies = ["test"]
|
95
|
+
person.hobbies # => ["test"]
|
96
|
+
|
97
|
+
person.something = "foo"
|
98
|
+
person.something # => "foo"
|
99
|
+
person.something = 123
|
100
|
+
person.something # => 123
|
101
|
+
person.something = nil # => raises TypeError
|
102
|
+
```
|
103
|
+
|
74
104
|
## Development
|
75
105
|
|
76
106
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -83,3 +113,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Fire-D
|
|
83
113
|
|
84
114
|
[test-badge]: https://travis-ci.org/Fire-Dragon-DoL/fried-schema.svg?branch=master
|
85
115
|
[test-link]: https://travis-ci.org/Fire-Dragon-DoL/fried-schema
|
116
|
+
[fried-typings-link]: https://github.com/Fire-Dragon-DoL/fried-typings
|
data/lib/fried/schema/version.rb
CHANGED