Class: DbCompile::Function

Inherits:
Construct show all
Defined in:
lib/dbcompile/function.rb

Instance Attribute Summary

Attributes inherited from Construct

#dependencies, #name, #path, #root_path

Instance Method Summary collapse

Methods inherited from Construct

#does_one_exist?, #execute, #initialize, #source

Constructor Details

This class inherits a constructor from DbCompile::Construct

Instance Method Details

#build_pathObject



3
4
5
# File 'lib/dbcompile/function.rb', line 3

def build_path
  @path = File.join('functions', "#{name}.sql")
end

#verifyObject



7
8
9
10
11
12
13
14
# File 'lib/dbcompile/function.rb', line 7

def verify
  sql = nil
  case ActiveRecord::Base.connection.class.to_s
    when 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
      sql = "SELECT proname FROM pg_proc WHERE proname = '#{name.downcase}';"
  end
  return does_one_exist?(sql) if sql
end