module Sequel::Dataset::StoredProcedureMethods

  1. lib/sequel/adapters/utils/stored_procedures.rb
Parent: Dataset

Methods

Public Instance

  1. call
  2. inspect
  3. run
  4. sproc_args
  5. sproc_name
  6. sproc_type=

Attributes

sproc_args [W]

The name of the stored procedure to call

sproc_name [RW]

The name of the stored procedure to call

Public Instance methods

call (*args, &block)

Call the stored procedure with the given args

[show source]
# File lib/sequel/adapters/utils/stored_procedures.rb, line 11
def call(*args, &block)
  sp = clone
  sp.sproc_args = args
  sp.run(&block)
end
inspect ()

Programmer friendly string showing this is a stored procedure, showing the name of the procedure.

[show source]
# File lib/sequel/adapters/utils/stored_procedures.rb, line 19
def inspect
  "<#{self.class.name}/StoredProcedure name=#{@sproc_name}>"
end
run (&block)

Run the stored procedure with the current args on the database

[show source]
# File lib/sequel/adapters/utils/stored_procedures.rb, line 24
def run(&block)
  case @sproc_type
  when :select, :all
    all(&block)
  when :first
    first
  when :insert
    insert
  when :update
    update
  when :delete
    delete
  end
end
sproc_type= (type)

Set the type of the stored procedure and override the corresponding _sql method to return the empty string (since the result will be ignored anyway).

[show source]
# File lib/sequel/adapters/utils/stored_procedures.rb, line 42
def sproc_type=(type)
  @sproc_type = type
  @opts[:sql] = ''
end