Module: Bullet::Dependency
- Defined in:
- lib/bullet/dependency.rb
Instance Method Summary collapse
- #active_record6_or_older? ⇒ Boolean
- #active_record70? ⇒ Boolean
- #active_record71? ⇒ Boolean
- #active_record72? ⇒ Boolean
- #active_record7? ⇒ Boolean
- #active_record80? ⇒ Boolean
- #active_record81? ⇒ Boolean
- #active_record8? ⇒ Boolean
- #active_record? ⇒ Boolean
- #active_record_version ⇒ Object
- #mongoid4x? ⇒ Boolean
- #mongoid5x? ⇒ Boolean
- #mongoid6x? ⇒ Boolean
- #mongoid7x? ⇒ Boolean
- #mongoid8x? ⇒ Boolean
- #mongoid9x? ⇒ Boolean
- #mongoid? ⇒ Boolean
- #mongoid_version ⇒ Object
Instance Method Details
#active_record6_or_older? ⇒ Boolean
55 56 57 |
# File 'lib/bullet/dependency.rb', line 55 def active_record6_or_older? active_record? && ::ActiveRecord::VERSION::MAJOR < 7 end |
#active_record70? ⇒ Boolean
67 68 69 |
# File 'lib/bullet/dependency.rb', line 67 def active_record70? active_record7? && ::ActiveRecord::VERSION::MINOR == 0 end |
#active_record71? ⇒ Boolean
71 72 73 |
# File 'lib/bullet/dependency.rb', line 71 def active_record71? active_record7? && ::ActiveRecord::VERSION::MINOR == 1 end |
#active_record72? ⇒ Boolean
75 76 77 |
# File 'lib/bullet/dependency.rb', line 75 def active_record72? active_record7? && ::ActiveRecord::VERSION::MINOR == 2 end |
#active_record7? ⇒ Boolean
59 60 61 |
# File 'lib/bullet/dependency.rb', line 59 def active_record7? active_record? && ::ActiveRecord::VERSION::MAJOR == 7 end |
#active_record80? ⇒ Boolean
79 80 81 |
# File 'lib/bullet/dependency.rb', line 79 def active_record80? active_record8? && ::ActiveRecord::VERSION::MINOR == 0 end |
#active_record81? ⇒ Boolean
83 84 85 |
# File 'lib/bullet/dependency.rb', line 83 def active_record81? active_record8? && ::ActiveRecord::VERSION::MINOR == 1 end |
#active_record8? ⇒ Boolean
63 64 65 |
# File 'lib/bullet/dependency.rb', line 63 def active_record8? active_record? && ::ActiveRecord::VERSION::MAJOR == 8 end |
#active_record? ⇒ Boolean
9 10 11 |
# File 'lib/bullet/dependency.rb', line 9 def active_record? @active_record ||= defined?(::ActiveRecord) end |
#active_record_version ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bullet/dependency.rb', line 13 def active_record_version @active_record_version ||= begin if active_record6_or_older? raise "Bullet no longer supports active_record #{::ActiveRecord::VERSION::STRING}" elsif active_record70? 'active_record70' elsif active_record71? 'active_record71' elsif active_record72? 'active_record72' elsif active_record80? 'active_record80' elsif active_record81? 'active_record81' else raise "Bullet does not support active_record #{::ActiveRecord::VERSION::STRING} yet" end end end |
#mongoid4x? ⇒ Boolean
87 88 89 |
# File 'lib/bullet/dependency.rb', line 87 def mongoid4x? mongoid? && ::Mongoid::VERSION =~ /\A4/ end |
#mongoid5x? ⇒ Boolean
91 92 93 |
# File 'lib/bullet/dependency.rb', line 91 def mongoid5x? mongoid? && ::Mongoid::VERSION =~ /\A5/ end |
#mongoid6x? ⇒ Boolean
95 96 97 |
# File 'lib/bullet/dependency.rb', line 95 def mongoid6x? mongoid? && ::Mongoid::VERSION =~ /\A6/ end |
#mongoid7x? ⇒ Boolean
99 100 101 |
# File 'lib/bullet/dependency.rb', line 99 def mongoid7x? mongoid? && ::Mongoid::VERSION =~ /\A7/ end |
#mongoid8x? ⇒ Boolean
103 104 105 |
# File 'lib/bullet/dependency.rb', line 103 def mongoid8x? mongoid? && ::Mongoid::VERSION =~ /\A8/ end |
#mongoid9x? ⇒ Boolean
107 108 109 |
# File 'lib/bullet/dependency.rb', line 107 def mongoid9x? mongoid? && ::Mongoid::VERSION =~ /\A9/ end |
#mongoid? ⇒ Boolean
5 6 7 |
# File 'lib/bullet/dependency.rb', line 5 def mongoid? @mongoid ||= defined?(::Mongoid) end |
#mongoid_version ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bullet/dependency.rb', line 34 def mongoid_version @mongoid_version ||= begin if mongoid4x? 'mongoid4x' elsif mongoid5x? 'mongoid5x' elsif mongoid6x? 'mongoid6x' elsif mongoid7x? 'mongoid7x' elsif mongoid8x? 'mongoid8x' elsif mongoid9x? 'mongoid9x' else raise "Bullet does not support mongoid #{::Mongoid::VERSION} yet" end end end |