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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0418e83aaae7d67b616dab559f7f5986430d022
4
- data.tar.gz: da31edddd52610cd95b14868b797b4197b508a68
3
+ metadata.gz: 69c38215fcc942031f12c6c101120e4e2b045c4e
4
+ data.tar.gz: c696731f9c9098b6a1437acaa79831a89c5a85cf
5
5
  SHA512:
6
- metadata.gz: cf21cdf1b18b9af6190d790214e24009ab48c679d18f4d12b40d97952053d0752e1363d59dc8921a77cf3b845de07327381e412fa600bebaaa1193d3b7fe40de
7
- data.tar.gz: 999ba235c7156753d37c5f8a3a8a70dc5f980fde4598e37d4ca6c597cc92db8ce04dac4bc6a88daba63c789a9512083587e80da87e5bec3c60b57c88e8d76efc
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, calculation_string)
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
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_compliable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond