restpack_serializer 0.4.23 → 0.4.24
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f41191ba4961b7f1ce4651b4fd1f510b9e784ff9
|
4
|
+
data.tar.gz: b07c073cbccfa5964092ad108350f25aea0d1e26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7c256addcf1c9212a02f2aeab7aca61a0f66b2e5ad0bd1ad9e5acebc59397359be5825d86dca3915ee087985f135a9d2bc5153889eb1496555468eb2f08b494
|
7
|
+
data.tar.gz: 2435d8486616017591fb7f6041e39e6f66c69f06645822252da5eddd87b24c48cef73eb7118913c4761891be414de20dbb797914b8a2c4db69847e5e7da2e592
|
@@ -28,10 +28,6 @@ module RestPack
|
|
28
28
|
|
29
29
|
class InvalidInclude < Exception; end
|
30
30
|
|
31
|
-
def array_as_json(models, context = {})
|
32
|
-
as_json(models, context)
|
33
|
-
end
|
34
|
-
|
35
31
|
def as_json(model, context = {})
|
36
32
|
return if model.nil?
|
37
33
|
if model.kind_of?(Array)
|
@@ -84,6 +80,10 @@ module RestPack
|
|
84
80
|
module ClassMethods
|
85
81
|
attr_accessor :model_class, :key
|
86
82
|
|
83
|
+
def array_as_json(models, context = {})
|
84
|
+
new.as_json(models, context)
|
85
|
+
end
|
86
|
+
|
87
87
|
def as_json(model, context = {})
|
88
88
|
new.as_json(model, context)
|
89
89
|
end
|
@@ -83,9 +83,9 @@ describe RestPack::Serializer do
|
|
83
83
|
}
|
84
84
|
]
|
85
85
|
end
|
86
|
-
context "
|
86
|
+
context "#array_as_json" do
|
87
87
|
it "results in a serialized array" do
|
88
|
-
serializer.array_as_json(people).should == [
|
88
|
+
serializer.class.array_as_json(people).should == [
|
89
89
|
{
|
90
90
|
id: '123', name: 'Gavin', description: 'This is person #123',
|
91
91
|
href: '/people/123', custom_key: 'custom value for model id 123'
|