Module: Bullet::Dependency
- Included in:
- Bullet, Bullet::Detector::NPlusOneQuery, Rack
- Defined in:
- lib/bullet/dependency.rb
Instance Method Summary collapse
- #active_record30? ⇒ Boolean
- #active_record31? ⇒ Boolean
- #active_record32? ⇒ Boolean
- #active_record3? ⇒ Boolean
- #active_record40? ⇒ Boolean
- #active_record41? ⇒ Boolean
- #active_record42? ⇒ Boolean
- #active_record4? ⇒ Boolean
- #active_record? ⇒ Boolean
- #active_record_version ⇒ Object
- #mongoid2x? ⇒ Boolean
- #mongoid3x? ⇒ Boolean
- #mongoid4x? ⇒ Boolean
- #mongoid? ⇒ Boolean
- #mongoid_version ⇒ Object
- #rails? ⇒ Boolean
Instance Method Details
#active_record30? ⇒ Boolean
51 52 53 |
# File 'lib/bullet/dependency.rb', line 51 def active_record30? active_record3? && ::ActiveRecord::VERSION::MINOR == 0 end |
#active_record31? ⇒ Boolean
55 56 57 |
# File 'lib/bullet/dependency.rb', line 55 def active_record31? active_record3? && ::ActiveRecord::VERSION::MINOR == 1 end |
#active_record32? ⇒ Boolean
59 60 61 |
# File 'lib/bullet/dependency.rb', line 59 def active_record32? active_record3? && ::ActiveRecord::VERSION::MINOR == 2 end |
#active_record3? ⇒ Boolean
43 44 45 |
# File 'lib/bullet/dependency.rb', line 43 def active_record3? active_record? && ::ActiveRecord::VERSION::MAJOR == 3 end |
#active_record40? ⇒ Boolean
63 64 65 |
# File 'lib/bullet/dependency.rb', line 63 def active_record40? active_record4? && ::ActiveRecord::VERSION::MINOR == 0 end |
#active_record41? ⇒ Boolean
67 68 69 |
# File 'lib/bullet/dependency.rb', line 67 def active_record41? active_record4? && ::ActiveRecord::VERSION::MINOR == 1 end |
#active_record42? ⇒ Boolean
71 72 73 |
# File 'lib/bullet/dependency.rb', line 71 def active_record42? active_record4? && ::ActiveRecord::VERSION::MINOR == 2 end |
#active_record4? ⇒ Boolean
47 48 49 |
# File 'lib/bullet/dependency.rb', line 47 def active_record4? active_record? && ::ActiveRecord::VERSION::MAJOR == 4 end |
#active_record? ⇒ Boolean
7 8 9 |
# File 'lib/bullet/dependency.rb', line 7 def active_record? @active_record ||= defined? ::ActiveRecord end |
#active_record_version ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bullet/dependency.rb', line 15 def active_record_version @active_record_version ||= begin if active_record30? 'active_record3' elsif active_record31? || active_record32? 'active_record3x' elsif active_record40? 'active_record4' elsif active_record41? 'active_record41' elsif active_record42? 'active_record42' end end end |
#mongoid2x? ⇒ Boolean
75 76 77 |
# File 'lib/bullet/dependency.rb', line 75 def mongoid2x? mongoid? && ::Mongoid::VERSION =~ /\A2\.[4-8]/ end |
#mongoid3x? ⇒ Boolean
79 80 81 |
# File 'lib/bullet/dependency.rb', line 79 def mongoid3x? mongoid? && ::Mongoid::VERSION =~ /\A3/ end |
#mongoid4x? ⇒ Boolean
83 84 85 |
# File 'lib/bullet/dependency.rb', line 83 def mongoid4x? mongoid? && ::Mongoid::VERSION =~ /\A4/ end |
#mongoid? ⇒ Boolean
3 4 5 |
# File 'lib/bullet/dependency.rb', line 3 def mongoid? @mongoid ||= defined? ::Mongoid end |
#mongoid_version ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bullet/dependency.rb', line 31 def mongoid_version @mongoid_version ||= begin if mongoid2x? 'mongoid2x' elsif mongoid3x? 'mongoid3x' elsif mongoid4x? 'mongoid4x' end end end |
#rails? ⇒ Boolean
11 12 13 |
# File 'lib/bullet/dependency.rb', line 11 def rails? @rails ||= defined? ::Rails end |