statisfy 0.0.4 → 0.0.6

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: b0232129b80c1b67a7e31c77256fcfea55d199e8bddb41d5acc75738290b54ed
4
- data.tar.gz: f9172db49c79f90d71e49907220db46772991bacda7356eac9dea539e900b115
3
+ metadata.gz: 6383d7143334e6448a05a5afb28b751f35afc830e04a2ad93dfe58a31a63a55f
4
+ data.tar.gz: eaf65b189c72a4fa77a439d4aff01bd6eeacf653036194e70085823433476e4f
5
5
  SHA512:
6
- metadata.gz: 1a7329d1ccd0da87a4eee455a885dc46b8e6bbcc24f1805348b77558114b8d946430ea33a443b432aba59f4e4a60314b4b53336539e1240e4afaffe4b1d33b51
7
- data.tar.gz: 5cc4383205544ea34da8bf25b1683237f7f89e241dc393376cc1d4ac0f478ecf2cc2bfc91e885db4d0b89d2337af7adc9eeea30766b253f41949cdbfc4287d41
6
+ metadata.gz: ff8563a77a395cee961fbed96a2b58df75d9d284f737b30341f448cd0cd6f5e7c46b9dd64f3fc077f1c1dafc3ee8de7228f6c48d8bc195fcd5af15f22bd374ac
7
+ data.tar.gz: dfb1216d2ffb054c81f9055da931bb8d0e766ff148a95cb090afbccdffd36d27c8fd72fd55d8f5b73f5f0b54e8d381e23ab8392681cf9ea4cf337aac39f5e153
@@ -0,0 +1,35 @@
1
+ require "ostruct"
2
+
3
+ module Statisfy
4
+ module Model
5
+ def self.included(klass)
6
+ klass.extend(ClassMethods)
7
+ klass.class_eval do
8
+ @statisfy = {}
9
+ end
10
+ end
11
+
12
+ module ClassMethods
13
+ def count(params)
14
+ raise ArgumentError, "Missing :as parameter" unless params[:as]
15
+
16
+ class_name = params[:as].to_s.camelize
17
+
18
+ eval <<-RUBY, binding, __FILE__, __LINE__ + 1
19
+ class ::Statisfy::#{class_name}
20
+ include Statisfy::Counter
21
+ end
22
+ RUBY
23
+
24
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
25
+ def self.#{params[:as]}
26
+ ::Statisfy::#{class_name}
27
+ end
28
+ RUBY
29
+
30
+ "::Statisfy::#{class_name}".constantize.send(__method__, **params)
31
+ end
32
+ alias aggregate count
33
+ end
34
+ end
35
+ end
data/lib/statisfy.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "statisfy/configuration"
4
4
  require_relative "statisfy/counter"
5
5
  require_relative "statisfy/aggregate"
6
6
  require_relative "statisfy/monthly"
7
+ require_relative "statisfy/model"
7
8
 
8
9
  module Statisfy
9
10
  class Error < StandardError; 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.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Villeneuve
@@ -119,6 +119,7 @@ files:
119
119
  - lib/statisfy/aggregate.rb
120
120
  - lib/statisfy/configuration.rb
121
121
  - lib/statisfy/counter.rb
122
+ - lib/statisfy/model.rb
122
123
  - lib/statisfy/monthly.rb
123
124
  - lib/statisfy/subscriber.rb
124
125
  homepage: https://github.com/Michaelvilleneuve/statisfy