Method: Sequel::SequelMethods#virtual_row

Defined in:
lib/sequel/core.rb

#virtual_row(&block) ⇒ Object

If the supplied block takes a single argument, yield an SQL::VirtualRow instance to the block argument. Otherwise, evaluate the block in the context of a SQL::VirtualRow instance.

Sequel.virtual_row{a} # Sequel::SQL::Identifier.new(:a)
Sequel.virtual_row{|o| o.a} # Sequel::SQL::Function.new(:a)


414
415
416
417
418
419
420
421
422
# File 'lib/sequel/core.rb', line 414

def virtual_row(&block)
  vr = VIRTUAL_ROW
  case block.arity
  when -1, 0
    vr.instance_exec(&block)
  else
    yield(vr)
  end  
end