Module: Sequel::Dataset::MergeBlockCopy

Defined in:
lib/sequel/oracle_extensions/merge.rb

Overview

Module used by Dataset#merge that has the effect of making all dataset methods into !-style methods that modify the receiver.

Instance Method Summary collapse

Instance Method Details

#clone(opts = nil) ⇒ Object

Merge the given options into the receiver’s options and return the receiver instead of cloning the receiver.



200
201
202
203
# File 'lib/sequel/oracle_extensions/merge.rb', line 200

def clone(opts = nil)
  @opts.merge!(opts)
  self
end

#eachObject

Raises:

  • (Error)


166
# File 'lib/sequel/oracle_extensions/merge.rb', line 166

def each; raise Error, "each cannot be invoked inside a merge block." end

#insert(*args, &block) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/sequel/oracle_extensions/merge.rb', line 181

def insert(*args, &block)
  args = [ args ] unless args.empty?
  args.push([Sequel.virtual_row(&block)]) if block
  @opts[:insert] = args.inject([]) do |r,a|
    if Hash === a.first
     raise Error, "Invalid insert arguments" unless a.size == 1
      r.concat a.first.to_a
    elsif a.size == 2
      raise Error, "Invalid insert arguments" unless a.all?{|v| Array===v && v.size==2}
     a.first.each_with_index{|k,i| r.push([k,a.last[i]]) }
     r
  else
      raise Error, "Invalid insert arguments"
    end
 end
end

#into(t) ⇒ Object



167
# File 'lib/sequel/oracle_extensions/merge.rb', line 167

def into(t) @opts[:into] = t end

#using(t) ⇒ Object



168
# File 'lib/sequel/oracle_extensions/merge.rb', line 168

def using(t) @opts[:using] = t end