module ActiveRecord::PLSQL::Pipelined::ClassMethods
Public Instance Methods
arel_table()
click to toggle source
Calls superclass method
# File lib/active_record/plsql/pipelined.rb, line 68 def arel_table if pipelined? @arel_table ||= Arel::Table.new(table_name_with_arguments, engine: arel_engine, as: pipelined_function_alias) else super end end
pipelined_arguments()
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 18 def pipelined_arguments raise PipelinedFunctionError, "Pipelined function didn't set" unless pipelined? @pipelined_arguments ||= get_pipelined_arguments end
pipelined_arguments_names()
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 23 def pipelined_arguments_names pipelined_arguments.map(&:name) end
pipelined_function()
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 27 def pipelined_function @pipelined_function end
Also aliased as: pipelined?
pipelined_function=(function)
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 33 def pipelined_function=(function) case function when String, Symbol # Name without schema expected function_name = function.to_s.split('.').map(&:downcase).map(&:to_sym) case function_name.size when 2 pipelined_function = plsql.send(function_name.first)[function_name.second] when 1 pipelined_function = PLSQL::PipelinedFunction.find(plsql, function_name.first) else raise ArgumentError, 'Setting schema via string not supported yed' end raise ArgumentError, 'Pipelined function not found by string: %s' % function unless pipelined_function when ::PLSQL::PipelinedFunction, nil pipelined_function = function else raise ArgumentError, 'Unsupported type of pipelined function: %s' % function.inspect end if pipelined_function && pipelined_function.overloaded? raise ArgumentError, 'Overloaded functions are not supported yet' end @pipelined_function = pipelined_function @pipelined_arguments = nil @table_name = pipelined_function_name if @pipelined_function end
pipelined_function_alias()
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 76 def pipelined_function_alias # GET_USER_BY_NAME => GUBN @pipelined_function.procedure.scan(/^\w|_\w/).join('').gsub('_', '') end
pipelined_function_name()
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 62 def pipelined_function_name return @full_function_name if defined? @full_function_name package_name, function_name = @pipelined_function.package, @pipelined_function.procedure @full_function_name = [package_name, function_name].compact.join('.') end
table_exist?()
click to toggle source
Calls superclass method
# File lib/active_record/plsql/pipelined.rb, line 87 def table_exist? pipelined? || super end
table_name_with_arguments()
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 81 def table_name_with_arguments @table_name_with_arguments ||= PipelinedFunctionTableName.new( "TABLE(%s(%s))" % [table_name, pipelined_arguments.map{|a| ":#{a.name}"}.join(',')] ) end
Private Instance Methods
get_pipelined_arguments()
click to toggle source
# File lib/active_record/plsql/pipelined.rb, line 93 def get_pipelined_arguments # Always select arguments of first function (overloading not supported) arguments_metadata = pipelined_function.arguments[0].sort_by {|arg| arg[1][:position]} arguments_metadata.map do |(name, argument)| ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new(name.to_s, nil, argument[:data_type], pipelined_function_name) end end
relation()
click to toggle source
Calls superclass method
# File lib/active_record/plsql/pipelined.rb, line 101 def relation return super unless pipelined? @relation ||= PipelinedRelation.new(self, arel_table) end