Class: Mkxms::Mssql::Function

Inherits:
Object
  • Object
show all
Includes:
ExtendedProperties, Property::Hosting, Property::SchemaScoped, Utils::SchemaQualifiedName
Defined in:
lib/mkxms/mssql/function_handler.rb

Constant Summary collapse

SQL_OBJECT_TYPE =
'FUNCTION'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ExtendedProperties

#extended_properties

Methods included from Property::Hosting

#extended_properties_sql

Methods included from Property::SchemaScoped

#property_subject_identifiers, #subitem_extended_properties_sql

Constructor Details

#initialize(attrs) ⇒ Function

Returns a new instance of Function.



14
15
16
17
18
19
20
# File 'lib/mkxms/mssql/function_handler.rb', line 14

def initialize(attrs)
  @schema = attrs['schema']
  @name = attrs['name']
  @definition = ''
  @references = []
  @param_properties = Hash.new {|h, k| h[k] = ''}
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



23
24
25
# File 'lib/mkxms/mssql/function_handler.rb', line 23

def definition
  @definition
end

#nameObject

Returns the value of attribute name.



22
23
24
# File 'lib/mkxms/mssql/function_handler.rb', line 22

def name
  @name
end

#param_propertiesObject (readonly)

Returns the value of attribute param_properties.



23
24
25
# File 'lib/mkxms/mssql/function_handler.rb', line 23

def param_properties
  @param_properties
end

#referencesObject (readonly)

Returns the value of attribute references.



23
24
25
# File 'lib/mkxms/mssql/function_handler.rb', line 23

def references
  @references
end

#schemaObject

Returns the value of attribute schema.



22
23
24
# File 'lib/mkxms/mssql/function_handler.rb', line 22

def schema
  @schema
end

Instance Method Details

#param_properties_sqlObject



30
31
32
33
34
# File 'lib/mkxms/mssql/function_handler.rb', line 30

def param_properties_sql
  @param_properties.each_pair.map do |k, v|
    Property.addition_sql(k[1], v, property_subject_identifiers + ['PARAMETER', Utils.unquoted_name(k[0])])
  end
end

#qualified_nameObject



36
37
38
# File 'lib/mkxms/mssql/function_handler.rb', line 36

def qualified_name
  "#@schema.#@name"
end

#to_sqlObject



25
26
27
28
# File 'lib/mkxms/mssql/function_handler.rb', line 25

def to_sql
  mvdef = AccessObjectDefinition.replace_object_name(definition, "[{filename}]")
  ([mvdef] + extended_properties_sql + param_properties_sql).join("\n")
end