jsonapi_compliable 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonapi_compliable/stats/payload.rb +10 -4
- data/lib/jsonapi_compliable/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: 69c38215fcc942031f12c6c101120e4e2b045c4e
|
4
|
+
data.tar.gz: c696731f9c9098b6a1437acaa79831a89c5a85cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c03156dbf5888c1ad8a13a79a7be1958ed54952f812126f25c5916279a32fc7474ebe19955c995ecd8ed5d1582ef4b7d10bed6aeb3cb393c4852b969d044931
|
7
|
+
data.tar.gz: 2f3658e3e8793911d19c7e894fcd8ccb106e7b4d68453744ae7570ce3d89e060fccd67cb2a055ecd944c4fd078e44a26d495a032172030e153b66fda783f7e3e
|
@@ -12,7 +12,7 @@ module JsonapiCompliable
|
|
12
12
|
@directive.each_pair do |name, calculation|
|
13
13
|
stats[name] = {}
|
14
14
|
|
15
|
-
each_calculation(name, calculation) do |calc, function|
|
15
|
+
each_calculation(name, parse_calculation(calculation)) do |calc, function|
|
16
16
|
stats[name][calc] = function.call(@scope, name)
|
17
17
|
end
|
18
18
|
end
|
@@ -21,14 +21,20 @@ module JsonapiCompliable
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
def each_calculation(name,
|
25
|
-
calculations = calculation_string.split(',').map(&:to_sym)
|
26
|
-
|
24
|
+
def each_calculation(name, calculations)
|
27
25
|
calculations.each do |calc|
|
28
26
|
function = @dsl.stat(name, calc)
|
29
27
|
yield calc, function
|
30
28
|
end
|
31
29
|
end
|
30
|
+
|
31
|
+
def parse_calculation(calculation)
|
32
|
+
if calculation.is_a?(String)
|
33
|
+
calculation.split(',').map(&:to_sym)
|
34
|
+
else
|
35
|
+
calculation.map(&:to_sym)
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|