class Flounder::Expression::Builder

Attributes

domain[RW]

Public Class Methods

new(domain) click to toggle source
# File lib/flounder/expression.rb, line 130
def initialize domain
  @domain = domain
end

Public Instance Methods

call(&block) click to toggle source
# File lib/flounder/expression.rb, line 136
def call &block
  instance_eval(&block)
end
interpret_conditions(entity, conditions) click to toggle source

Conditions are interpreted relative to an entity.

# File lib/flounder/expression.rb, line 141
def interpret_conditions entity, conditions
  # The method we need is in there...
  query = Flounder::Query::Select.new(domain, entity)
  engine = Flounder::Engine.new(domain.connection_pool)

  and_expr = BinaryOp.new(domain, 'AND')

  # TODO parse_conditions and its call tree is not really something that
  # belongs into the query object - we should create a new abstraction here.
  query.parse_conditions(*conditions) { |bit| 
    and_expr.concat(ConditionBit.new(domain, engine, bit)) }

  and_expr
end
method_missing(sym, *args, &block) click to toggle source
# File lib/flounder/expression.rb, line 159
def method_missing sym, *args, &block
  raise ArgumentError, "No blocks in sql execution context." if block

  FunCall.new(domain, sym, args)
end
respond_to?(sym, include_all=false) click to toggle source
# File lib/flounder/expression.rb, line 156
def respond_to? sym, include_all=false
  true
end