Class: ActiveRecord::QueryMethods::WhereChain
- Inherits:
-
Object
- Object
- ActiveRecord::QueryMethods::WhereChain
- Defined in:
- lib/postgres_ext/active_record/relation/query_methods.rb
Instance Method Summary collapse
- #all(opts, *rest) ⇒ Object
- #any(opts, *rest) ⇒ Object
- #contained_in_array(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
64 65 66 |
# File 'lib/postgres_ext/active_record/relation/query_methods.rb', line 64 def all(opts, *rest) equality_to_function('ALL', opts, rest) end |
#any(opts, *rest) ⇒ Object
60 61 62 |
# File 'lib/postgres_ext/active_record/relation/query_methods.rb', line 60 def any(opts, *rest) equality_to_function('ANY', opts, rest) end |
#contained_in_array(opts, *rest) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/postgres_ext/active_record/relation/query_methods.rb', line 36 def contained_in_array(opts, *rest) build_where_chain(opts, rest) do |rel| case rel when Arel::Nodes::In, Arel::Nodes::Equality column = left_column(rel) || column_from_association(rel) equality_for_hstore(rel) if column.type == :hstore if column.type == :hstore Arel::Nodes::ContainedInHStore.new(rel.left, rel.right) elsif column.respond_to?(:array) && column.array Arel::Nodes::ContainedInArray.new(rel.left, rel.right) else Arel::Nodes::ContainsINet.new(rel.left, rel.right) end else raise ArgumentError, "Invalid argument for .where.overlap(), got #{rel.class}" end end end |
#contained_within(opts, *rest) ⇒ Object
8 9 10 |
# File 'lib/postgres_ext/active_record/relation/query_methods.rb', line 8 def contained_within(opts, *rest) substitute_comparisons(opts, rest, Arel::Nodes::ContainedWithin, 'contained_within') end |
#contained_within_or_equals(opts, *rest) ⇒ Object
12 13 14 |
# File 'lib/postgres_ext/active_record/relation/query_methods.rb', line 12 def contained_within_or_equals(opts, *rest) substitute_comparisons(opts, rest, Arel::Nodes::ContainedWithinEquals, 'contained_within_or_equals') end |
#contains(opts, *rest) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/postgres_ext/active_record/relation/query_methods.rb', line 16 def contains(opts, *rest) build_where_chain(opts, rest) do |rel| case rel when Arel::Nodes::In, Arel::Nodes::Equality column = left_column(rel) || column_from_association(rel) equality_for_hstore(rel) if column.type == :hstore if column.type == :hstore Arel::Nodes::ContainsHStore.new(rel.left, rel.right) elsif column.respond_to?(:array) && column.array Arel::Nodes::ContainsArray.new(rel.left, rel.right) else Arel::Nodes::ContainsINet.new(rel.left, rel.right) end else raise ArgumentError, "Invalid argument for .where.overlap(), got #{rel.class}" end end end |
#contains_or_equals(opts, *rest) ⇒ Object
56 57 58 |
# File 'lib/postgres_ext/active_record/relation/query_methods.rb', line 56 def contains_or_equals(opts, *rest) substitute_comparisons(opts, rest, Arel::Nodes::ContainsEquals, 'contains_or_equals') end |