statisfy 0.0.8 → 0.0.10

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
  SHA256:
3
- metadata.gz: b1fc7262fee03a85f7aec7875b837371114d2205e2e88ed1d4adb372c83025a7
4
- data.tar.gz: 14e250747429e2dc67861b13bc6c249cb07fb1a616b9248f37e69d46578c2f9b
3
+ metadata.gz: fefc77edb493e9b299329483e6eee64b163557b2320f03225a492dd60731860e
4
+ data.tar.gz: 15efdf6901e8c514011b538da459b2dc2ebd37bcad6e85ec5d5b6d9482116974
5
5
  SHA512:
6
- metadata.gz: 84612c386cf3ec0e0c941404cf0f74c3acba3c37f41cfc2f3ae34ab689f8ffcd603a1a16d27e7c15efc5b3ee9ab76d05a15f882a2a739b0b7ea08ff324d5dba6
7
- data.tar.gz: 4980ac9dd156ea28aeae6f1ab1c48f6ec5804b572eca27427f05abebf82a1db747f0e9d27c97a1d5a0e100ef580083d3018e0bcf19d7a086f239145375707459
6
+ metadata.gz: 611b63cc3aed721b7f2410af146af9d6a410c8672fa55d9a46dae4231ab8a26d067a7ebb004202611b82d2d35aeb17db0595dcf47c1712bc7ff56f084adbc416
7
+ data.tar.gz: b9e84f2a477d91ae022f41a0b8f3f6d604be81654dd83900076d72e6d26c341ea4189b2fe65225cccd3eb1ee389f90095e2ab44cc6f4142ee613c50c309661b8
@@ -22,7 +22,7 @@ module Statisfy
22
22
 
23
23
  if start_at.present? || scope&.created_at.present?
24
24
  start_at ||= scope.created_at
25
- n_months = (Time.zone.today.year + Time.zone.today.month) - (start_at.year + start_at.month)
25
+ n_months = (Time.zone.today.year * 12 + Time.zone.today.month) - (start_at.year * 12 + start_at.month)
26
26
  end
27
27
 
28
28
  relevant_months = (0..n_months).map do |i|
@@ -69,7 +69,7 @@ module Statisfy
69
69
 
70
70
  define_method(instance_name) do
71
71
  model = instance_name.camelize.constantize
72
- @subject ||= model.find_by(id: params["id"])
72
+ @subject ||= @params.instance_of?(model) ? @params : model.find_by(id: params["id"])
73
73
  end
74
74
  alias_method :subject, instance_name
75
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statisfy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Villeneuve