Module: Arel::Predications
- Defined in:
- activerecord/lib/arel/predications.rb
Instance Method Summary collapse
- #between(other) ⇒ Object
- #concat(other) ⇒ Object
- #contains(other) ⇒ Object
- #does_not_match(other, escape = nil, case_sensitive = false) ⇒ Object
- #does_not_match_all(others, escape = nil) ⇒ Object
- #does_not_match_any(others, escape = nil) ⇒ Object
- #does_not_match_regexp(other, case_sensitive = true) ⇒ Object
- #eq(other) ⇒ Object
- #eq_all(others) ⇒ Object
- #eq_any(others) ⇒ Object
- #gt(right) ⇒ Object
- #gt_all(others) ⇒ Object
- #gt_any(others) ⇒ Object
- #gteq(right) ⇒ Object
- #gteq_all(others) ⇒ Object
- #gteq_any(others) ⇒ Object
- #in(other) ⇒ Object
- #in_all(others) ⇒ Object
- #in_any(others) ⇒ Object
- #is_distinct_from(other) ⇒ Object
- #is_not_distinct_from(other) ⇒ Object
- #lt(right) ⇒ Object
- #lt_all(others) ⇒ Object
- #lt_any(others) ⇒ Object
- #lteq(right) ⇒ Object
- #lteq_all(others) ⇒ Object
- #lteq_any(others) ⇒ Object
- #matches(other, escape = nil, case_sensitive = false) ⇒ Object
- #matches_all(others, escape = nil, case_sensitive = false) ⇒ Object
- #matches_any(others, escape = nil, case_sensitive = false) ⇒ Object
- #matches_regexp(other, case_sensitive = true) ⇒ Object
- #not_between(other) ⇒ Object
- #not_eq(other) ⇒ Object
- #not_eq_all(others) ⇒ Object
- #not_eq_any(others) ⇒ Object
- #not_in(other) ⇒ Object
- #not_in_all(others) ⇒ Object
- #not_in_any(others) ⇒ Object
- #overlaps(other) ⇒ Object
- #quoted_array(others) ⇒ Object
- #when(right) ⇒ Object
Instance Method Details
#between(other) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'activerecord/lib/arel/predications.rb', line 37 def between(other) if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1 self.in([]) elsif open_ended?(other.begin) if open_ended?(other.end) if infinity?(other.begin) == 1 || infinity?(other.end) == -1 self.in([]) else not_in([]) end elsif other.exclude_end? lt(other.end) else lteq(other.end) end elsif open_ended?(other.end) gteq(other.begin) elsif other.exclude_end? gteq(other.begin).and(lt(other.end)) elsif other.begin == other.end eq(other.begin) else left = quoted_node(other.begin) right = quoted_node(other.end) Nodes::Between.new(self, Nodes::And.new([left, right])) end end |
#concat(other) ⇒ Object
215 216 217 |
# File 'activerecord/lib/arel/predications.rb', line 215 def concat(other) Nodes::Concat.new self, other end |
#contains(other) ⇒ Object
219 220 221 |
# File 'activerecord/lib/arel/predications.rb', line 219 def contains(other) Arel::Nodes::Contains.new self, quoted_node(other) end |
#does_not_match(other, escape = nil, case_sensitive = false) ⇒ Object
147 148 149 |
# File 'activerecord/lib/arel/predications.rb', line 147 def does_not_match(other, escape = nil, case_sensitive = false) Nodes::DoesNotMatch.new self, quoted_node(other), escape, case_sensitive end |
#does_not_match_all(others, escape = nil) ⇒ Object
159 160 161 |
# File 'activerecord/lib/arel/predications.rb', line 159 def does_not_match_all(others, escape = nil) grouping_all :does_not_match, others, escape end |
#does_not_match_any(others, escape = nil) ⇒ Object
155 156 157 |
# File 'activerecord/lib/arel/predications.rb', line 155 def does_not_match_any(others, escape = nil) grouping_any :does_not_match, others, escape end |
#does_not_match_regexp(other, case_sensitive = true) ⇒ Object
151 152 153 |
# File 'activerecord/lib/arel/predications.rb', line 151 def does_not_match_regexp(other, case_sensitive = true) Nodes::NotRegexp.new self, quoted_node(other), case_sensitive end |
#eq(other) ⇒ Object
17 18 19 |
# File 'activerecord/lib/arel/predications.rb', line 17 def eq(other) Nodes::Equality.new self, quoted_node(other) end |
#eq_all(others) ⇒ Object
33 34 35 |
# File 'activerecord/lib/arel/predications.rb', line 33 def eq_all(others) grouping_all :eq, quoted_array(others) end |
#eq_any(others) ⇒ Object
29 30 31 |
# File 'activerecord/lib/arel/predications.rb', line 29 def eq_any(others) grouping_any :eq, others end |
#gt(right) ⇒ Object
175 176 177 |
# File 'activerecord/lib/arel/predications.rb', line 175 def gt(right) Nodes::GreaterThan.new self, quoted_node(right) end |
#gt_all(others) ⇒ Object
183 184 185 |
# File 'activerecord/lib/arel/predications.rb', line 183 def gt_all(others) grouping_all :gt, others end |
#gt_any(others) ⇒ Object
179 180 181 |
# File 'activerecord/lib/arel/predications.rb', line 179 def gt_any(others) grouping_any :gt, others end |
#gteq(right) ⇒ Object
163 164 165 |
# File 'activerecord/lib/arel/predications.rb', line 163 def gteq(right) Nodes::GreaterThanOrEqual.new self, quoted_node(right) end |
#gteq_all(others) ⇒ Object
171 172 173 |
# File 'activerecord/lib/arel/predications.rb', line 171 def gteq_all(others) grouping_all :gteq, others end |
#gteq_any(others) ⇒ Object
167 168 169 |
# File 'activerecord/lib/arel/predications.rb', line 167 def gteq_any(others) grouping_any :gteq, others end |
#in(other) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'activerecord/lib/arel/predications.rb', line 65 def in(other) case other when Arel::SelectManager Arel::Nodes::In.new(self, other.ast) when Enumerable Nodes::In.new self, quoted_array(other) else Nodes::In.new self, quoted_node(other) end end |
#in_all(others) ⇒ Object
80 81 82 |
# File 'activerecord/lib/arel/predications.rb', line 80 def in_all(others) grouping_all :in, others end |
#in_any(others) ⇒ Object
76 77 78 |
# File 'activerecord/lib/arel/predications.rb', line 76 def in_any(others) grouping_any :in, others end |
#is_distinct_from(other) ⇒ Object
25 26 27 |
# File 'activerecord/lib/arel/predications.rb', line 25 def is_distinct_from(other) Nodes::IsDistinctFrom.new self, quoted_node(other) end |
#is_not_distinct_from(other) ⇒ Object
21 22 23 |
# File 'activerecord/lib/arel/predications.rb', line 21 def is_not_distinct_from(other) Nodes::IsNotDistinctFrom.new self, quoted_node(other) end |
#lt(right) ⇒ Object
187 188 189 |
# File 'activerecord/lib/arel/predications.rb', line 187 def lt(right) Nodes::LessThan.new self, quoted_node(right) end |
#lt_all(others) ⇒ Object
195 196 197 |
# File 'activerecord/lib/arel/predications.rb', line 195 def lt_all(others) grouping_all :lt, others end |
#lt_any(others) ⇒ Object
191 192 193 |
# File 'activerecord/lib/arel/predications.rb', line 191 def lt_any(others) grouping_any :lt, others end |
#lteq(right) ⇒ Object
199 200 201 |
# File 'activerecord/lib/arel/predications.rb', line 199 def lteq(right) Nodes::LessThanOrEqual.new self, quoted_node(right) end |
#lteq_all(others) ⇒ Object
207 208 209 |
# File 'activerecord/lib/arel/predications.rb', line 207 def lteq_all(others) grouping_all :lteq, others end |
#lteq_any(others) ⇒ Object
203 204 205 |
# File 'activerecord/lib/arel/predications.rb', line 203 def lteq_any(others) grouping_any :lteq, others end |
#matches(other, escape = nil, case_sensitive = false) ⇒ Object
131 132 133 |
# File 'activerecord/lib/arel/predications.rb', line 131 def matches(other, escape = nil, case_sensitive = false) Nodes::Matches.new self, quoted_node(other), escape, case_sensitive end |
#matches_all(others, escape = nil, case_sensitive = false) ⇒ Object
143 144 145 |
# File 'activerecord/lib/arel/predications.rb', line 143 def matches_all(others, escape = nil, case_sensitive = false) grouping_all :matches, others, escape, case_sensitive end |
#matches_any(others, escape = nil, case_sensitive = false) ⇒ Object
139 140 141 |
# File 'activerecord/lib/arel/predications.rb', line 139 def matches_any(others, escape = nil, case_sensitive = false) grouping_any :matches, others, escape, case_sensitive end |
#matches_regexp(other, case_sensitive = true) ⇒ Object
135 136 137 |
# File 'activerecord/lib/arel/predications.rb', line 135 def matches_regexp(other, case_sensitive = true) Nodes::Regexp.new self, quoted_node(other), case_sensitive end |
#not_between(other) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'activerecord/lib/arel/predications.rb', line 84 def not_between(other) if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1 not_in([]) elsif open_ended?(other.begin) if open_ended?(other.end) if infinity?(other.begin) == 1 || infinity?(other.end) == -1 not_in([]) else self.in([]) end elsif other.exclude_end? gteq(other.end) else gt(other.end) end elsif open_ended?(other.end) lt(other.begin) else left = lt(other.begin) right = if other.exclude_end? gteq(other.end) else gt(other.end) end left.or(right) end end |
#not_eq(other) ⇒ Object
5 6 7 |
# File 'activerecord/lib/arel/predications.rb', line 5 def not_eq(other) Nodes::NotEqual.new self, quoted_node(other) end |
#not_eq_all(others) ⇒ Object
13 14 15 |
# File 'activerecord/lib/arel/predications.rb', line 13 def not_eq_all(others) grouping_all :not_eq, others end |
#not_eq_any(others) ⇒ Object
9 10 11 |
# File 'activerecord/lib/arel/predications.rb', line 9 def not_eq_any(others) grouping_any :not_eq, others end |
#not_in(other) ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'activerecord/lib/arel/predications.rb', line 112 def not_in(other) case other when Arel::SelectManager Arel::Nodes::NotIn.new(self, other.ast) when Enumerable Nodes::NotIn.new self, quoted_array(other) else Nodes::NotIn.new self, quoted_node(other) end end |
#not_in_all(others) ⇒ Object
127 128 129 |
# File 'activerecord/lib/arel/predications.rb', line 127 def not_in_all(others) grouping_all :not_in, others end |
#not_in_any(others) ⇒ Object
123 124 125 |
# File 'activerecord/lib/arel/predications.rb', line 123 def not_in_any(others) grouping_any :not_in, others end |
#overlaps(other) ⇒ Object
223 224 225 |
# File 'activerecord/lib/arel/predications.rb', line 223 def overlaps(other) Arel::Nodes::Overlaps.new self, quoted_node(other) end |
#quoted_array(others) ⇒ Object
227 228 229 |
# File 'activerecord/lib/arel/predications.rb', line 227 def quoted_array(others) others.map { |v| quoted_node(v) } end |