Class: Sequel::Dataset::PlaceholderLiteralizer::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/dataset/placeholder_literalizer.rb

Overview

Records the offsets at which the placeholder arguments are used in the SQL query.

Instance Method Summary collapse

Instance Method Details

#arg(v = (no_arg_given = true; @argn+=1)) ⇒ Object

Return an Argument with the specified position, or the next position. In general you shouldn’t mix calls with an argument and calls without an argument for the same receiver.



87
88
89
90
91
92
# File 'lib/sequel/dataset/placeholder_literalizer.rb', line 87

def arg(v=(no_arg_given = true; @argn+=1))
  unless no_arg_given
    @argn = v if @argn < v
  end
  Argument.new(self, v)
end

#loader(pl, dataset, &block) ⇒ Object

Yields the receiver and the dataset to the block, which should call #arg on the receiver for each placeholder argument, and return the dataset that you want to load.



80
81
82
# File 'lib/sequel/dataset/placeholder_literalizer.rb', line 80

def loader(pl, dataset, &block)
  pl.new(*process(dataset, &block))
end

#use(sql, arg, transformer) ⇒ Object

Record the offset at which the argument is used in the SQL query, and any transforming block.



96
97
98
# File 'lib/sequel/dataset/placeholder_literalizer.rb', line 96

def use(sql, arg, transformer)
  @args << [sql, sql.length, arg, transformer]
end