module ArelExtensions::Comparators
Public Instance Methods
!~(other)
click to toggle source
NOT_REGEXP function Negation of Regexp
# File lib/arel_extensions/comparators.rb, line 30 def !~(other) # arg = self.relation.engine.connection.schema_cache.columns_hash(self.relation.table_name)[self.name.to_s].type # if arg == :string || arg == :text Arel::Nodes::NotRegexp.new self, convert_regexp(other) # end end
<(other)
click to toggle source
# File lib/arel_extensions/comparators.rb, line 11 def <(other) Arel::Nodes::LessThan.new self, Arel::Nodes.build_quoted(other, self) end
<=(other)
click to toggle source
# File lib/arel_extensions/comparators.rb, line 15 def <=(other) Arel::Nodes::LessThanOrEqual.new self, Arel::Nodes.build_quoted(other, self) end
=~(other)
click to toggle source
REGEXP function Pattern matching using regular expressions
# File lib/arel_extensions/comparators.rb, line 21 def =~(other) # arg = self.relation.engine.connection.schema_cache.columns_hash(self.relation.table_name)[self.name.to_s].type # if arg == :string || arg == :text Arel::Nodes::Regexp.new self, convert_regexp(other) # end end
>(other)
click to toggle source
# File lib/arel_extensions/comparators.rb, line 3 def >(other) Arel::Nodes::GreaterThan.new self, Arel::Nodes.build_quoted(other, self) end
>=(other)
click to toggle source
# File lib/arel_extensions/comparators.rb, line 7 def >=(other) Arel::Nodes::GreaterThanOrEqual.new self, Arel::Nodes.build_quoted(other, self) end
Private Instance Methods
convert_regexp(other)
click to toggle source
Function used for not_regexp.
# File lib/arel_extensions/comparators.rb, line 40 def convert_regexp(other) case other when String # Do nothing. when Regexp other = other.source.gsub('\A','^') other.gsub!('\z','$') other.gsub!('\Z','$') other.gsub!('\d','[0-9]') other.gsub!('\D','[^0-9]') other.gsub!('\w','[0-9A-Za-z]') other.gsub!('\W','[^A-Za-z0-9_]') else raise(ArgumentError) end Arel::Nodes.build_quoted(other, self) end