Commit 81c1bce0a1db6b58e36060dfe6bece0c14938d24
1 parent
3ed18436
Exists in
master
and in
17 other branches
Moved ActiveRecord code to separate file
Showing
3 changed files
with
26 additions
and
22 deletions
Show diff stats
lib/groupdate.rb
1 | +require "active_support/time" | |
1 | 2 | require "groupdate/version" |
2 | -require "groupdate/scopes" | |
3 | 3 | require "groupdate/enumerable" |
4 | - | |
5 | -ActiveRecord::Base.send :extend, Groupdate::Scopes | |
6 | - | |
7 | -# hack for **unfixed** rails issue | |
8 | -# https://github.com/rails/rails/issues/7121 | |
9 | -module ActiveRecord | |
10 | - module Calculations | |
11 | - | |
12 | - private | |
13 | - | |
14 | - def column_alias_for_with_hack(*keys) | |
15 | - if keys.first.is_a?(Groupdate::OrderHack) | |
16 | - keys.first.field | |
17 | - else | |
18 | - column_alias_for_without_hack(*keys) | |
19 | - end | |
20 | - end | |
21 | - alias_method_chain :column_alias_for, :hack | |
22 | - | |
23 | - end | |
24 | -end | |
4 | +require "groupdate/active_record" | |
25 | 5 | |
26 | 6 | module Groupdate |
27 | 7 | mattr_accessor :week_start, :day_start, :time_zone | ... | ... |
... | ... | @@ -0,0 +1,23 @@ |
1 | +require "active_record" | |
2 | +require "groupdate/scopes" | |
3 | + | |
4 | +ActiveRecord::Base.send(:extend, Groupdate::Scopes) | |
5 | + | |
6 | +# hack for **unfixed** rails issue | |
7 | +# https://github.com/rails/rails/issues/7121 | |
8 | +module ActiveRecord | |
9 | + module Calculations | |
10 | + | |
11 | + private | |
12 | + | |
13 | + def column_alias_for_with_hack(*keys) | |
14 | + if keys.first.is_a?(Groupdate::OrderHack) | |
15 | + keys.first.field | |
16 | + else | |
17 | + column_alias_for_without_hack(*keys) | |
18 | + end | |
19 | + end | |
20 | + alias_method_chain :column_alias_for, :hack | |
21 | + | |
22 | + end | |
23 | +end | ... | ... |