Module: Arel::Predications
Do not use. This module is for internal use only.
Instance Method Summary
- #between(other)
- #concat(other)
- #contains(other)
- #does_not_match(other, escape = nil, case_sensitive = false)
- #does_not_match_all(others, escape = nil)
- #does_not_match_any(others, escape = nil)
- #does_not_match_regexp(other, case_sensitive = true)
- #eq(other)
- #eq_all(others)
- #eq_any(others)
- #gt(right)
- #gt_all(others)
- #gt_any(others)
- #gteq(right)
- #gteq_all(others)
- #gteq_any(others)
- #in(other)
- #in_all(others)
- #in_any(others)
- #is_distinct_from(other)
- #is_not_distinct_from(other)
- #lt(right)
- #lt_all(others)
- #lt_any(others)
- #lteq(right)
- #lteq_all(others)
- #lteq_any(others)
- #matches(other, escape = nil, case_sensitive = false)
- #matches_all(others, escape = nil, case_sensitive = false)
- #matches_any(others, escape = nil, case_sensitive = false)
- #matches_regexp(other, case_sensitive = true)
- #not_between(other)
- #not_eq(other)
- #not_eq_all(others)
- #not_eq_any(others)
- #not_in(other)
- #not_in_all(others)
- #not_in_any(others)
- #overlaps(other)
- #quoted_array(others)
- #when(right)
- #grouping_all(method_id, others, *extras) private
- #grouping_any(method_id, others, *extras) private
- #infinity?(value) ⇒ Boolean private
- #open_ended?(value) ⇒ Boolean private
- #quoted_node(other) private
- #unboundable?(value) ⇒ Boolean private
Instance Method Details
#between(other)
[ GitHub ]# 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)
[ GitHub ]#contains(other)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 17
def eq(other) Nodes::Equality.new self, quoted_node(other) end
#eq_all(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 33
def eq_all(others) grouping_all :eq, quoted_array(others) end
#eq_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 29
def eq_any(others) grouping_any :eq, others end
#grouping_all(method_id, others, *extras) (private)
[ GitHub ]#grouping_any(method_id, others, *extras) (private)
[ GitHub ]#gt(right)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 175
def gt(right) Nodes::GreaterThan.new self, quoted_node(right) end
#gt_all(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 183
def gt_all(others) grouping_all :gt, others end
#gt_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 179
def gt_any(others) grouping_any :gt, others end
#gteq(right)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 163
def gteq(right) Nodes::GreaterThanOrEqual.new self, quoted_node(right) end
#gteq_all(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 171
def gteq_all(others) grouping_all :gteq, others end
#gteq_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 167
def gteq_any(others) grouping_any :gteq, others end
#in(other)
[ GitHub ]# 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)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 80
def in_all(others) grouping_all :in, others end
#in_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 76
def in_any(others) grouping_any :in, others end
#infinity?(value) ⇒ Boolean
(private)
# File 'activerecord/lib/arel/predications.rb', line 248
def infinity?(value) value.respond_to?(:infinite?) && value.infinite? end
#is_distinct_from(other)
[ GitHub ]# 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)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 21
def is_not_distinct_from(other) Nodes::IsNotDistinctFrom.new self, quoted_node(other) end
#lt(right)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 187
def lt(right) Nodes::LessThan.new self, quoted_node(right) end
#lt_all(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 195
def lt_all(others) grouping_all :lt, others end
#lt_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 191
def lt_any(others) grouping_any :lt, others end
#lteq(right)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 199
def lteq(right) Nodes::LessThanOrEqual.new self, quoted_node(right) end
#lteq_all(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 207
def lteq_all(others) grouping_all :lteq, others end
#lteq_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 203
def lteq_any(others) grouping_any :lteq, others end
#matches(other, escape = nil, case_sensitive = false)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 5
def not_eq(other) Nodes::NotEqual.new self, quoted_node(other) end
#not_eq_all(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 13
def not_eq_all(others) grouping_all :not_eq, others end
#not_eq_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 9
def not_eq_any(others) grouping_any :not_eq, others end
#not_in(other)
[ GitHub ]# 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)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 127
def not_in_all(others) grouping_all :not_in, others end
#not_in_any(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 123
def not_in_any(others) grouping_any :not_in, others end
#open_ended?(value) ⇒ Boolean
(private)
# File 'activerecord/lib/arel/predications.rb', line 256
def open_ended?(value) value.nil? || infinity?(value) || unboundable?(value) end
#overlaps(other)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 223
def overlaps(other) Arel::Nodes::Overlaps.new self, quoted_node(other) end
#quoted_array(others)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 227
def quoted_array(others) others.map { |v| quoted_node(v) } end
#quoted_node(other) (private)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 244
def quoted_node(other) Nodes.build_quoted(other, self) end
#unboundable?(value) ⇒ Boolean
(private)
# File 'activerecord/lib/arel/predications.rb', line 252
def unboundable?(value) value.respond_to?(:unboundable?) && value.unboundable? end
#when(right)
[ GitHub ]# File 'activerecord/lib/arel/predications.rb', line 211
def when(right) Nodes::Case.new(self).when quoted_node(right) end