Class: Mao::Filter::Binary

Inherits:
Object
  • Object
show all
Includes:
Mao::Filter
Defined in:
lib/mao/filter.rb

Overview

A binary operation on two filters.

Instance Attribute Summary

Attributes included from Mao::Filter

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mao::Filter

#!=, #<, #<=, #==, #>, #>=, #and, finalize_or_literal, #in, #initialize, #null?, #or

Class Method Details

.sql(op, lhs, rhs) ⇒ Object

Used by Mao::Filter.sql to generate the actual SQL for a column reference.



134
135
136
137
138
139
140
141
142
143
# File 'lib/mao/filter.rb', line 134

def self.sql(op, lhs, rhs)
  s = "("
  s << Mao::Filter.sql(lhs)
  s << " "
  s << op
  s << " "
  s << Mao::Filter.sql(rhs)
  s << ")"
  s
end

Instance Method Details

#finalizeObject

Produces an array which becomes part of the resulting Mao::Query’s options, used by Mao::Query#sql.



125
126
127
128
129
130
# File 'lib/mao/filter.rb', line 125

def finalize
  [:Binary,
   @options[:op],
   Mao::Filter.finalize_or_literal(@options[:lhs]),
   Mao::Filter.finalize_or_literal(@options[:rhs])]
end