/
by_star.rb.bak
43 lines (34 loc) · 945 Bytes
/
by_star.rb.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'chronic'
require 'by_star/shared'
require 'by_star/range_calculations'
require 'by_star/time_ext'
require 'by_star/vanilla'
require 'by_star/neighbours'
require 'by_star/calculations/count'
require 'by_star/calculations/sum'
require 'by_star/calculations'
module ByStar
def self.included(base)
base.extend ClassMethods
base.send(:include, InstanceMethods)
base.class_eval do
def self.by_star_field(value=nil)
@by_star_field ||= value
@by_star_field || "#{self.table_name}.created_at"
end
end
end
module ClassMethods
include RangeCalculations
include Shared
include Vanilla
include Calculations
end
module InstanceMethods
include Neighbours
end
class ParseError < Exception; end
class MonthNotFound < Exception; end
end
ActiveRecord::Base.send :include, ByStar
ActiveRecord::Relation.send :include, ByStar if ActiveRecord.const_defined?("Relation")