Class: Mkxms::Mssql::ClrFunctionHandler

Inherits:
Object
  • Object
show all
Includes:
PropertyHandler::ElementHandler
Defined in:
lib/mkxms/mssql/clr_function_handler.rb

Defined Under Namespace

Classes: ResultTableColumnHandler

Instance Method Summary collapse

Methods included from PropertyHandler::ElementHandler

#handle_property_element

Constructor Details

#initialize(functions, node) ⇒ ClrFunctionHandler

Returns a new instance of ClrFunctionHandler.



107
108
109
110
111
112
113
114
# File 'lib/mkxms/mssql/clr_function_handler.rb', line 107

def initialize(functions, node)
  a = node.attributes
  
  @function = ClrFunction.new(a).tap do |f|
    store_properties_on f
    functions << f
  end
end

Instance Method Details

#handle_column_element(parse) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/mkxms/mssql/clr_function_handler.rb', line 153

def handle_column_element(parse)
  a = parse.node.attributes
  ClrFunction::ResultTable::Column.new(
    a['name'],
    ResultType.new(
      a['type-schema'],
      a['type'],
      a['capacity'],
      a['precision'],
      a['scale'],
      a['collation'],
    )
  ).tap do |col|
    @result_table.columns << col
    # Dispatch parse for column properties
    parse.context = ResultTableColumnHandler.new(col)
  end
end

#handle_implementation_element(parse) ⇒ Object



116
117
118
119
# File 'lib/mkxms/mssql/clr_function_handler.rb', line 116

def handle_implementation_element(parse)
  a = parse.node.attributes
  @function.clr_impl = ClrMethod.new(a['assembly'], a['class'], a['method'])
end

#handle_parameter_element(parse) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/mkxms/mssql/clr_function_handler.rb', line 121

def handle_parameter_element(parse)
  a = parse.node.attributes
  Parameter.new(
    a['name'],
    a['type-schema'],
    a['type'],
    a['capacity'],
    a['precision'],
    a['scale'],
    a['default'],
    a['output'],
  ).tap do |param|
    @function.params << param
    parse.context = ParameterHandler.new(param)
  end
end

#handle_result_table_element(parse) ⇒ Object



149
150
151
# File 'lib/mkxms/mssql/clr_function_handler.rb', line 149

def handle_result_table_element(parse)
  @function.result_table = @result_table = ClrFunction::ResultTable.new
end

#handle_returns_element(parse) ⇒ Object



138
139
140
141
142
143
144
145
146
147
# File 'lib/mkxms/mssql/clr_function_handler.rb', line 138

def handle_returns_element(parse)
  a = parse.node.attributes
  @function.returns = ResultType.new(
    a['type-schema'],
    a['type'],
    a['capacity'],
    a['precision'],
    a['scale'],
  )
end