Class: OCI8::BindArgumentHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/oci8/object.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ BindArgumentHelper

Returns a new instance of BindArgumentHelper.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/oci8/object.rb', line 64

def initialize(*args)
  if args.length == 1 and args[0].is_a? Hash
    @arg_str = args[0].keys.collect do |key| "#{key}=>:#{key}"; end.join(', ')
    @bind_vars = args[0]
  else
    ary = []
    @bind_vars = {}
    args.each_with_index do |obj, idx|
      key = ':' + (idx + 1).to_s
      ary << key
      @bind_vars[key] = obj
    end
    @arg_str = ary.join(', ')
  end
end

Instance Attribute Details

#arg_strObject (readonly)

Returns the value of attribute arg_str.



63
64
65
# File 'lib/oci8/object.rb', line 63

def arg_str
  @arg_str
end

Instance Method Details

#exec(con, csr) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/oci8/object.rb', line 80

def exec(con, csr)
  @bind_vars.each do |key, val|
    if val.is_a? OCI8::Object::Base
      tdo = con.get_tdo_by_class(val.class)
      csr.bind_param(key, nil, :named_type_internal, tdo)
      csr[key].attributes = val
    else
      csr.bind_param(key, val)
    end
  end
  csr.exec
  @bind_vars.each do |key, val|
    if val.is_a? OCI8::Object::Base
      val.instance_variable_set(:@attributes, csr[key].attributes)
    end
  end
end