Module: BabySqueel::Compat::QueryMethods
- Defined in:
- lib/baby_squeel/compat.rb
Instance Method Summary collapse
-
#eager_load(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#eager_load.
-
#group(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#group.
-
#having(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#having.
-
#includes(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#includes.
-
#joins(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#joins.
-
#order(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#order.
-
#preload(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#preload.
- #reorder(*args, &block) ⇒ Object
-
#select(*args, &block) ⇒ Object
Heads up, Array#select conflicts with ActiveRecord::QueryMethods#select.
-
#where(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#where.
Instance Method Details
#eager_load(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#eager_load
89 90 91 92 93 94 95 |
# File 'lib/baby_squeel/compat.rb', line 89 def eager_load(*args, &block) if block_given? && args.empty? super KeyPath.evaluate(&block) else super end end |
#group(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#group
140 141 142 143 144 145 146 |
# File 'lib/baby_squeel/compat.rb', line 140 def group(*args, &block) if block_given? && args.empty? grouping(&block) else super end end |
#having(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#having
149 150 151 152 153 154 155 |
# File 'lib/baby_squeel/compat.rb', line 149 def having(*args, &block) if block_given? && args.empty? when_having(&block) else super end end |
#includes(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#includes
80 81 82 83 84 85 86 |
# File 'lib/baby_squeel/compat.rb', line 80 def includes(*args, &block) if block_given? && args.empty? super KeyPath.evaluate(&block) else super end end |
#joins(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#joins
71 72 73 74 75 76 77 |
# File 'lib/baby_squeel/compat.rb', line 71 def joins(*args, &block) if block_given? && args.empty? joining(&block) else super end end |
#order(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#order
123 124 125 126 127 128 129 |
# File 'lib/baby_squeel/compat.rb', line 123 def order(*args, &block) if block_given? && args.empty? ordering(&block) else super end end |
#preload(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#preload
98 99 100 101 102 103 104 |
# File 'lib/baby_squeel/compat.rb', line 98 def preload(*args, &block) if block_given? && args.empty? super KeyPath.evaluate(&block) else super end end |
#reorder(*args, &block) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/baby_squeel/compat.rb', line 131 def reorder(*args, &block) if block_given? && args.empty? reordering(&block) else super end end |
#select(*args, &block) ⇒ Object
Heads up, Array#select conflicts with ActiveRecord::QueryMethods#select. So, if arity is given to the block, we’ll use Array#select. Otherwise, you’ll be in a DSL block.
Model.select { This is DSL }
Model.select { |m| This is not DSL }
114 115 116 117 118 119 120 |
# File 'lib/baby_squeel/compat.rb', line 114 def select(*args, &block) if block_given? && args.empty? && block.arity.zero? selecting(&block) else super end end |
#where(*args, &block) ⇒ Object
Overrides ActiveRecord::QueryMethods#where
158 159 160 161 162 163 164 |
# File 'lib/baby_squeel/compat.rb', line 158 def where(*args, &block) if block_given? && args.empty? where.has(&block) else super end end |