cerulean 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cerulean.rb +11 -3
- 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: 27afad5987be82e117bf2fa411fde273586a3b12
|
4
|
+
data.tar.gz: 200728caeb772a89305dc50961ab9208b58e9208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5f129539e9c7c5ba3fc7307163e1f552628a64b9bac3bf5585b08ee28cf144a2fca0808981ed9bd5b853f7f04f0a418b930cac8ba3b98eb0ebe44e823ba4ce
|
7
|
+
data.tar.gz: 62bcb90d95cacf2aadb44b96b2c7cba3bc8a5032ed61e4594052d9e723991cde5ed75d47c907be059e0fd54fa01eb2e0e128d131a41e01b81988200fa3eaa094
|
data/lib/cerulean.rb
CHANGED
@@ -60,11 +60,19 @@ module Cerulean
|
|
60
60
|
@declared ||= {} #Hashie::Mash.new(params)
|
61
61
|
end
|
62
62
|
|
63
|
-
def present(object, opts
|
63
|
+
def present(object, **opts)
|
64
64
|
if object.is_a?(Array) || object.is_a?(ActiveRecord::Relation)
|
65
|
-
|
65
|
+
if opts.any?
|
66
|
+
render json: object.map { |el| meta[:presenter].new(el).as_json(**opts) }
|
67
|
+
else
|
68
|
+
render json: object.map { |el| meta[:presenter].new(el).as_json() }
|
69
|
+
end
|
66
70
|
else
|
67
|
-
|
71
|
+
if opts.any?
|
72
|
+
render json: meta[:presenter].new(object).as_json(**opts)
|
73
|
+
else
|
74
|
+
render json: meta[:presenter].new(object).as_json()
|
75
|
+
end
|
68
76
|
end
|
69
77
|
end
|
70
78
|
|