Module: Arel::Predications
- Defined in:
- 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 |
# File '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)) 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
213 214 215 |
# File 'lib/arel/predications.rb', line 213 def concat(other) Nodes::Concat.new self, other end |
#contains(other) ⇒ Object
217 218 219 |
# File 'lib/arel/predications.rb', line 217 def contains(other) Arel::Nodes::Contains.new self, quoted_node(other) end |
#does_not_match(other, escape = nil, case_sensitive = false) ⇒ Object
145 146 147 |
# File 'lib/arel/predications.rb', line 145 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
157 158 159 |
# File 'lib/arel/predications.rb', line 157 def does_not_match_all(others, escape = nil) grouping_all :does_not_match, others, escape end |
#does_not_match_any(others, escape = nil) ⇒ Object
153 154 155 |
# File 'lib/arel/predications.rb', line 153 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
149 150 151 |
# File 'lib/arel/predications.rb', line 149 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 '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 '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 'lib/arel/predications.rb', line 29 def eq_any(others) grouping_any :eq, others end |
#gt(right) ⇒ Object
173 174 175 |
# File 'lib/arel/predications.rb', line 173 def gt(right) Nodes::GreaterThan.new self, quoted_node(right) end |
#gt_all(others) ⇒ Object
181 182 183 |
# File 'lib/arel/predications.rb', line 181 def gt_all(others) grouping_all :gt, others end |
#gt_any(others) ⇒ Object
177 178 179 |
# File 'lib/arel/predications.rb', line 177 def gt_any(others) grouping_any :gt, others end |
#gteq(right) ⇒ Object
161 162 163 |
# File 'lib/arel/predications.rb', line 161 def gteq(right) Nodes::GreaterThanOrEqual.new self, quoted_node(right) end |
#gteq_all(others) ⇒ Object
169 170 171 |
# File 'lib/arel/predications.rb', line 169 def gteq_all(others) grouping_all :gteq, others end |
#gteq_any(others) ⇒ Object
165 166 167 |
# File 'lib/arel/predications.rb', line 165 def gteq_any(others) grouping_any :gteq, others end |
#in(other) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/arel/predications.rb', line 63 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
78 79 80 |
# File 'lib/arel/predications.rb', line 78 def in_all(others) grouping_all :in, others end |
#in_any(others) ⇒ Object
74 75 76 |
# File 'lib/arel/predications.rb', line 74 def in_any(others) grouping_any :in, others end |
#is_distinct_from(other) ⇒ Object
25 26 27 |
# File '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 'lib/arel/predications.rb', line 21 def is_not_distinct_from(other) Nodes::IsNotDistinctFrom.new self, quoted_node(other) end |
#lt(right) ⇒ Object
185 186 187 |
# File 'lib/arel/predications.rb', line 185 def lt(right) Nodes::LessThan.new self, quoted_node(right) end |
#lt_all(others) ⇒ Object
193 194 195 |
# File 'lib/arel/predications.rb', line 193 def lt_all(others) grouping_all :lt, others end |
#lt_any(others) ⇒ Object
189 190 191 |
# File 'lib/arel/predications.rb', line 189 def lt_any(others) grouping_any :lt, others end |
#lteq(right) ⇒ Object
197 198 199 |
# File 'lib/arel/predications.rb', line 197 def lteq(right) Nodes::LessThanOrEqual.new self, quoted_node(right) end |
#lteq_all(others) ⇒ Object
205 206 207 |
# File 'lib/arel/predications.rb', line 205 def lteq_all(others) grouping_all :lteq, others end |
#lteq_any(others) ⇒ Object
201 202 203 |
# File 'lib/arel/predications.rb', line 201 def lteq_any(others) grouping_any :lteq, others end |
#matches(other, escape = nil, case_sensitive = false) ⇒ Object
129 130 131 |
# File 'lib/arel/predications.rb', line 129 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
141 142 143 |
# File 'lib/arel/predications.rb', line 141 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
137 138 139 |
# File 'lib/arel/predications.rb', line 137 def matches_any(others, escape = nil, case_sensitive = false) grouping_any :matches, others, escape, case_sensitive end |
#matches_regexp(other, case_sensitive = true) ⇒ Object
133 134 135 |
# File 'lib/arel/predications.rb', line 133 def matches_regexp(other, case_sensitive = true) Nodes::Regexp.new self, quoted_node(other), case_sensitive end |
#not_between(other) ⇒ Object
82 83 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 |
# File 'lib/arel/predications.rb', line 82 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 '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 '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 'lib/arel/predications.rb', line 9 def not_eq_any(others) grouping_any :not_eq, others end |
#not_in(other) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/arel/predications.rb', line 110 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
125 126 127 |
# File 'lib/arel/predications.rb', line 125 def not_in_all(others) grouping_all :not_in, others end |
#not_in_any(others) ⇒ Object
121 122 123 |
# File 'lib/arel/predications.rb', line 121 def not_in_any(others) grouping_any :not_in, others end |
#overlaps(other) ⇒ Object
221 222 223 |
# File 'lib/arel/predications.rb', line 221 def overlaps(other) Arel::Nodes::Overlaps.new self, quoted_node(other) end |
#quoted_array(others) ⇒ Object
225 226 227 |
# File 'lib/arel/predications.rb', line 225 def quoted_array(others) others.map { |v| quoted_node(v) } end |