Sha256: b621fe338437c8dc21ec0a43b46e263002a196a2161a172de59857153a94edc2
Contents?: true
Size: 1.37 KB
Versions: 15
Compression:
Stored size: 1.37 KB
Contents
module Torque module PostgreSQL module Arel nodes = ::Arel::Nodes inflix = nodes::InfixOperation visitors = ::Arel::Visitors::PostgreSQL default_alias = :visit_Arel_Nodes_InfixOperation Math = Module.new INFLIX_OPERATION = { 'Overlaps' => :'&&', 'Contains' => :'@>', 'ContainedBy' => :'<@', 'HasKey' => :'?', 'HasAllKeys' => :'?&', 'HasAnyKeys' => :'?|', 'StrictlyLeft' => :'<<', 'StrictlyRight' => :'>>', 'DoesntRightExtend' => :'&<', 'DoesntLeftExtend' => :'&>', 'AdjacentTo' => :'-|-', }.freeze INFLIX_OPERATION.each do |operator_name, operator| klass = Class.new(inflix) klass.send(:define_method, :initialize) { |*args| super(operator, *args) } nodes.const_set(operator_name, klass) visitors.send(:alias_method, :"visit_Arel_Nodes_#{operator_name}", default_alias) # Don't worry about quoting here, if the right side is something that # doesn't need quoting, it will leave it as it is Math.send(:define_method, operator_name.underscore) do |other| klass.new(self, nodes.build_quoted(other, self)) end end ::Arel::Nodes::Node.include(Math) ::Arel::Attribute.include(Math) end end end
Version data entries
15 entries across 15 versions & 1 rubygems