Module: Torque::PostgreSQL::Arel
- Defined in:
- lib/torque/postgresql/arel/nodes.rb,
lib/torque/postgresql/arel/visitors.rb,
lib/torque/postgresql/arel/operations.rb,
lib/torque/postgresql/arel/join_source.rb,
lib/torque/postgresql/arel/select_manager.rb,
lib/torque/postgresql/arel/infix_operation.rb
Defined Under Namespace
Modules: JoinSource, Nodes, Operations, SelectManager, Visitors
Constant Summary collapse
- Math =
Module.new
Class Method Summary collapse
Class Method Details
.build_operations(operations) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/torque/postgresql/arel/infix_operation.rb', line 8 def self.build_operations(operations) default_alias = :visit_Arel_Nodes_InfixOperation operations&.each do |name, operator| klass_name = name.to_s.camelize next if ::Arel::Nodes.const_defined?(klass_name) klass = Class.new(::Arel::Nodes::InfixOperation) operator = (-operator).to_sym klass.send(:define_method, :initialize) { |*args| super(operator, *args) } ::Arel::Nodes.const_set(klass_name, klass) visitor = :"visit_Arel_Nodes_#{klass_name}" ::Arel::Visitors::PostgreSQL.send(:alias_method, visitor, 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, klass_name.underscore) { |other| klass.new(self, other) } end end |