Module: Bullet::Dependency

Included in:
Bullet, Bullet::Detector::NPlusOneQuery, Bullet::Detector::UnusedEagerLoading, Rack
Defined in:
lib/bullet/dependency.rb

Instance Method Summary collapse

Instance Method Details

#active_record40?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/bullet/dependency.rb', line 85

def active_record40?
  active_record4? && ::ActiveRecord::VERSION::MINOR == 0
end

#active_record41?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/bullet/dependency.rb', line 89

def active_record41?
  active_record4? && ::ActiveRecord::VERSION::MINOR == 1
end

#active_record42?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/bullet/dependency.rb', line 93

def active_record42?
  active_record4? && ::ActiveRecord::VERSION::MINOR == 2
end

#active_record4?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/bullet/dependency.rb', line 65

def active_record4?
  active_record? && ::ActiveRecord::VERSION::MAJOR == 4
end

#active_record50?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/bullet/dependency.rb', line 97

def active_record50?
  active_record5? && ::ActiveRecord::VERSION::MINOR == 0
end

#active_record51?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/bullet/dependency.rb', line 101

def active_record51?
  active_record5? && ::ActiveRecord::VERSION::MINOR == 1
end

#active_record52?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/bullet/dependency.rb', line 105

def active_record52?
  active_record5? && ::ActiveRecord::VERSION::MINOR == 2
end

#active_record5?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/bullet/dependency.rb', line 69

def active_record5?
  active_record? && ::ActiveRecord::VERSION::MAJOR == 5
end

#active_record60?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/bullet/dependency.rb', line 109

def active_record60?
  active_record6? && ::ActiveRecord::VERSION::MINOR == 0
end

#active_record61?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/bullet/dependency.rb', line 113

def active_record61?
  active_record6? && ::ActiveRecord::VERSION::MINOR == 1
end

#active_record6?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/bullet/dependency.rb', line 73

def active_record6?
  active_record? && ::ActiveRecord::VERSION::MAJOR == 6
end

#active_record70?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/bullet/dependency.rb', line 117

def active_record70?
  active_record7? && ::ActiveRecord::VERSION::MINOR == 0
end

#active_record71?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/bullet/dependency.rb', line 121

def active_record71?
  active_record7? && ::ActiveRecord::VERSION::MINOR == 1
end

#active_record72?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/bullet/dependency.rb', line 125

def active_record72?
  active_record7? && ::ActiveRecord::VERSION::MINOR == 2
end

#active_record7?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/bullet/dependency.rb', line 77

def active_record7?
  active_record? && ::ActiveRecord::VERSION::MAJOR == 7
end

#active_record80?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/bullet/dependency.rb', line 129

def active_record80?
  active_record8? && ::ActiveRecord::VERSION::MINOR == 0
end

#active_record8?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/bullet/dependency.rb', line 81

def active_record8?
  active_record? && ::ActiveRecord::VERSION::MAJOR == 8
end

#active_record?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/bullet/dependency.rb', line 9

def active_record?
  @active_record ||= defined?(::ActiveRecord)
end

#active_record_versionObject



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
44
# File 'lib/bullet/dependency.rb', line 13

def active_record_version
  @active_record_version ||=
    begin
      if active_record40?
        'active_record4'
      elsif active_record41?
        'active_record41'
      elsif active_record42?
        'active_record42'
      elsif active_record50?
        'active_record5'
      elsif active_record51?
        'active_record5'
      elsif active_record52?
        'active_record52'
      elsif active_record60?
        'active_record60'
      elsif active_record61?
        'active_record61'
      elsif active_record70?
        'active_record70'
      elsif active_record71?
        'active_record71'
      elsif active_record72?
        'active_record72'
      elsif active_record80?
        'active_record80'
      else
        raise "Bullet does not support active_record #{::ActiveRecord::VERSION::STRING} yet"
      end
    end
end

#mongoid4x?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/bullet/dependency.rb', line 133

def mongoid4x?
  mongoid? && ::Mongoid::VERSION =~ /\A4/
end

#mongoid5x?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/bullet/dependency.rb', line 137

def mongoid5x?
  mongoid? && ::Mongoid::VERSION =~ /\A5/
end

#mongoid6x?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/bullet/dependency.rb', line 141

def mongoid6x?
  mongoid? && ::Mongoid::VERSION =~ /\A6/
end

#mongoid7x?Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/bullet/dependency.rb', line 145

def mongoid7x?
  mongoid? && ::Mongoid::VERSION =~ /\A7/
end

#mongoid8x?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'lib/bullet/dependency.rb', line 149

def mongoid8x?
  mongoid? && ::Mongoid::VERSION =~ /\A8/
end

#mongoid?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/bullet/dependency.rb', line 5

def mongoid?
  @mongoid ||= defined?(::Mongoid)
end

#mongoid_versionObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bullet/dependency.rb', line 46

def mongoid_version
  @mongoid_version ||=
    begin
      if mongoid4x?
        'mongoid4x'
      elsif mongoid5x?
        'mongoid5x'
      elsif mongoid6x?
        'mongoid6x'
      elsif mongoid7x?
        'mongoid7x'
      elsif mongoid8x?
        'mongoid8x'
      else
        raise "Bullet does not support mongoid #{::Mongoid::VERSION} yet"
      end
    end
end