Class: Dbsketch::Rendering::SQL::OperationRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/dbsketch/rendering/sql/operation_renderer.rb

Instance Method Summary collapse

Instance Method Details

#create(operation) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dbsketch/rendering/sql/operation_renderer.rb', line 14

def create operation
	### Preconditions
	raise ArgumentError, "operation is not a Dbsketch::Model::Operation" unless operation.is_a? Dbsketch::Model::Operation
	###
	if operation.is_a? Dbsketch::Model::Function
		create_function operation
	elsif operation.is_a? Dbsketch::Model::Procedure
		create_procedure operation
	else
		raise ArgumentError, "#{operation.class} is an unknown subclass of Dbsketch::Model::Operation"
	end
end

#drop(operation) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dbsketch/rendering/sql/operation_renderer.rb', line 27

def drop operation
	### Preconditions
	raise ArgumentError, "operation is not a Dbsketch::Model::Operation" unless operation.is_a? Dbsketch::Model::Operation
	###
	if operation.is_a? Dbsketch::Model::Function
		keyword = "function"
		mssql_type = "FN"
	elsif operation.is_a? Dbsketch::Model::Procedure
		keyword = "procedure"
		mssql_type = "P"
	else
		raise ArgumentError, "#{operation.class} is an unknown subclass of Dbsketch::Model::Operation"
	end

	"if object_id('#{operation.name}', '#{mssql_type}') is not null drop #{keyword} #{operation.name}"
end