Module: ActiveRecordExtended::WhereChain
- Included in:
- ActiveRecord::QueryMethods::WhereChain
- Defined in:
- lib/active_record_extended/query_methods/where_chain.rb
Instance Method Summary collapse
- #all(opts, *rest) ⇒ Object
- #any(opts, *rest) ⇒ Object
- #contained_within(opts, *rest) ⇒ Object
- #contained_within_or_equals(opts, *rest) ⇒ Object
- #contains(opts, *rest) ⇒ Object
- #contains_or_equals(opts, *rest) ⇒ Object
- #overlap(opts, *rest) ⇒ Object
Instance Method Details
#all(opts, *rest) ⇒ Object
25 26 27 |
# File 'lib/active_record_extended/query_methods/where_chain.rb', line 25 def all(opts, *rest) equality_to_function("ALL", opts, rest) end |
#any(opts, *rest) ⇒ Object
21 22 23 |
# File 'lib/active_record_extended/query_methods/where_chain.rb', line 21 def any(opts, *rest) equality_to_function("ANY", opts, rest) end |
#contained_within(opts, *rest) ⇒ Object
9 10 11 |
# File 'lib/active_record_extended/query_methods/where_chain.rb', line 9 def contained_within(opts, *rest) substitute_comparisons(opts, rest, Arel::Nodes::ContainedWithin, "contained_within") end |
#contained_within_or_equals(opts, *rest) ⇒ Object
13 14 15 |
# File 'lib/active_record_extended/query_methods/where_chain.rb', line 13 def contained_within_or_equals(opts, *rest) substitute_comparisons(opts, rest, Arel::Nodes::ContainedWithinEquals, "contained_within_or_equals") end |
#contains(opts, *rest) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/active_record_extended/query_methods/where_chain.rb', line 29 def contains(opts, *rest) build_where_chain(opts, rest) do |arel| case arel when Arel::Nodes::In, Arel::Nodes::Equality column = left_column(arel) || column_from_association(arel) if i[hstore jsonb].include?(column.type) Arel::Nodes::ContainsHStore.new(arel.left, arel.right) elsif column.try(:array) Arel::Nodes::ContainsArray.new(arel.left, arel.right) else raise ArgumentError, "Invalid argument for .where.contains(), got #{arel.class}" end else raise ArgumentError, "Invalid argument for .where.contains(), got #{arel.class}" end end end |
#contains_or_equals(opts, *rest) ⇒ Object
17 18 19 |
# File 'lib/active_record_extended/query_methods/where_chain.rb', line 17 def contains_or_equals(opts, *rest) substitute_comparisons(opts, rest, Arel::Nodes::ContainsEquals, "contains_or_equals") end |
#overlap(opts, *rest) ⇒ Object
5 6 7 |
# File 'lib/active_record_extended/query_methods/where_chain.rb', line 5 def overlap(opts, *rest) substitute_comparisons(opts, rest, Arel::Nodes::Overlap, "overlap") end |