granola-schema 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcd59ea7f9c27652b7712bfc01142fc65a518bad
|
4
|
+
data.tar.gz: 0de079848da83488cb3cd17fd84b09e80e415528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52b664f758cf362273190515ff825df4c4bb6d97dc81222c8de2e3d7418094260c6fa585f85e8757a059bd4efbda8e7ed36eca1322b5718bc0efb0e57c702c6
|
7
|
+
data.tar.gz: 509e314bf8c198d426f14d368301b1c9f982b8d31187ebf98a929d69ae545aa1b3f70879d7566e1b15ea75e23aa2dba7e0f06f8aead7ca94b19e4a6027d14bcd
|
data/README.md
CHANGED
@@ -51,22 +51,33 @@ serializer.to_json #=> '[{"name":"John Doe",...},{...}]'
|
|
51
51
|
|
52
52
|
## Rack Helpers
|
53
53
|
|
54
|
-
If your application is based on
|
55
|
-
|
56
|
-
you can simply `include Granola::Rack` and you get access to the following
|
57
|
-
interface:
|
54
|
+
If your application is based on Rack, you can simply `include Granola::Rack` and
|
55
|
+
you get access to the following interface:
|
58
56
|
|
59
57
|
``` ruby
|
60
58
|
json(person) #=> This will try to infer PersonSerializer from a Person instance
|
61
59
|
json(person, with: AnotherSerializer)
|
62
60
|
```
|
63
61
|
|
64
|
-
*NOTE
|
65
|
-
|
66
|
-
|
62
|
+
*NOTE* The method relies on being an `env` method that returns the Rack
|
63
|
+
environment Hash in the same context where you call the method. See [the
|
64
|
+
documentation](./lib/granola/rack.rb) for further details.
|
67
65
|
|
68
|
-
|
69
|
-
[
|
66
|
+
This method returns a Rack response tuple that you can use like so (this example
|
67
|
+
uses [Cuba][], but similar code will work for other frameworks):
|
68
|
+
|
69
|
+
``` ruby
|
70
|
+
Cuba.plugin Granola::Rack
|
71
|
+
|
72
|
+
Cuba.define do
|
73
|
+
on get, "users/:id" do |id|
|
74
|
+
user = User[id]
|
75
|
+
halt json(user)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
[Cuba]: http://cuba.is
|
70
81
|
|
71
82
|
## Caching
|
72
83
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: granola-schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Sanguinetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: granola
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.
|
26
|
+
version: 0.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json-schema
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|