Class: WsdlMapper::SvcGeneration::OperationGenerator
- Inherits:
-
OperationGeneratorBase
- Object
- Generation::Base
- GeneratorBase
- OperationGeneratorBase
- WsdlMapper::SvcGeneration::OperationGenerator
- Defined in:
- lib/wsdl_mapper/svc_generation/operation_generator.rb
Direct Known Subclasses
Instance Method Summary (collapse)
- - (Object) generate_accessors(f, parts)
- - (Object) generate_body(service, port, op, in_out, name, result)
- - (Object) generate_body_class(f, name, parts)
- - (Object) generate_ctr(f, parts)
- - (Object) generate_header(service, port, op, in_out, name, result)
- - (Object) generate_header_class(f, name, parts)
- - (Object) generate_input_d10r(f, service, port, op)
- - (Object) generate_input_s8r(f, service, port, op)
- - (Object) generate_new_input(f, service, port, op)
- - (Object) generate_new_output(f, service, port, op)
- - (Object) generate_op_class(f, service, port, op)
- - (Object) generate_op_ctr(f, service, port, op)
- - (Object) generate_op_input_body(service, port, op, result)
- - (Object) generate_op_input_header(service, port, op, result)
- - (Object) generate_op_output_body(service, port, op, result)
- - (Object) generate_op_output_header(service, port, op, result)
- - (Object) generate_operation(service, port, op, result)
- - (Object) generate_output_d10r(f, service, port, op)
- - (Object) generate_output_s8r(f, service, port, op)
- - (Object) get_op_requires(service, port, op)
Methods inherited from GeneratorBase
Methods inherited from Generation::Base
#append_file_for, #file, #file_for, #generate_name, #get_formatter, #get_module_names, #get_type_name, #initialize, #type_file_for
Constructor Details
This class inherits a constructor from WsdlMapper::SvcGeneration::GeneratorBase
Instance Method Details
- (Object) generate_accessors(f, parts)
204 205 206 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 204 def generate_accessors(f, parts) f.attr_accessors *parts.map { |p| p.property_name.attr_name } end |
- (Object) generate_body(service, port, op, in_out, name, result)
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 182 def generate_body(service, port, op, in_out, name, result) modules = get_module_names service.name parts = get_body_parts in_out type_file_for name, result do |f| f.requires body_base.require_path f.in_modules modules do in_classes f, service.name.class_name, port.name.class_name, op.name.class_name do generate_body_class f, name, parts end end end end |
- (Object) generate_body_class(f, name, parts)
197 198 199 200 201 202 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 197 def generate_body_class(f, name, parts) f.in_sub_class name.class_name, body_base.name do generate_accessors f, parts generate_ctr f, parts end end |
- (Object) generate_ctr(f, parts)
208 209 210 211 212 213 214 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 208 def generate_ctr(f, parts) f.in_def :initialize, *parts.map { |p| "#{p.property_name.attr_name}: nil" } do parts.each do |p| f.assignment p.property_name.var_name, p.property_name.attr_name end end end |
- (Object) generate_header(service, port, op, in_out, name, result)
150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 150 def generate_header(service, port, op, in_out, name, result) modules = get_module_names service.name parts = get_header_parts in_out type_file_for name, result do |f| f.requires header_base.require_path f.in_modules modules do in_classes f, service.name.class_name, port.name.class_name, op.name.class_name do generate_header_class f, name, parts end end end end |
- (Object) generate_header_class(f, name, parts)
165 166 167 168 169 170 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 165 def generate_header_class(f, name, parts) f.in_sub_class name.class_name, header_base.name do generate_accessors f, parts generate_ctr f, parts end end |
- (Object) generate_input_d10r(f, service, port, op)
58 59 60 61 62 63 64 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 58 def generate_input_d10r(f, service, port, op) name = service_namer.get_input_d10r_name(service.type, port.type, op.type).name f.in_def :input_d10r do f.call :super f.statement "@input_d10r ||= #{name}" end end |
- (Object) generate_input_s8r(f, service, port, op)
40 41 42 43 44 45 46 47 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 40 def generate_input_s8r(f, service, port, op) name = service_namer.get_input_s8r_name(service.type, port.type, op.type).name type_directory_name = namer.get_s8r_type_directory_name.name f.in_def :input_s8r do f.call :super f.statement "@input_s8r ||= #{name}.new(#{type_directory_name})" end end |
- (Object) generate_new_input(f, service, port, op)
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 74 def generate_new_input(f, service, port, op) f.in_def :new_input, 'header: {}', 'body: {}' do f.call :super header_name = service_namer.get_input_header_name(service.type, port.type, op.type) body_name = service_namer.get_input_body_name(service.type, port.type, op.type) header_args = get_header_parts(op.type.input).any? ? '**header' : '' header = "#{header_name.name}.new(#{header_args})" body_args = get_body_parts(op.type.input).any? ? '**body' : '' body = "#{body_name.name}.new(#{body_args})" f.call :new_message, header, body end end |
- (Object) generate_new_output(f, service, port, op)
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 87 def generate_new_output(f, service, port, op) f.in_def :new_output, 'header: {}', 'body: {}' do f.call :super header_name = service_namer.get_output_header_name(service.type, port.type, op.type) body_name = service_namer.get_output_body_name(service.type, port.type, op.type) header_args = get_header_parts(op.type.output).any? ? '**header' : '' header = "#{header_name.name}.new(#{header_args})" body_args = get_body_parts(op.type.output).any? ? '**body' : '' body = "#{body_name.name}.new(#{body_args})" f.call :new_message, header, body end end |
- (Object) generate_op_class(f, service, port, op)
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 28 def generate_op_class(f, service, port, op) f.in_sub_class op.name.class_name, operation_base.name do generate_op_ctr f, service, port, op generate_new_input f, service, port, op generate_new_output f, service, port, op generate_input_s8r f, service, port, op generate_output_s8r f, service, port, op generate_input_d10r f, service, port, op generate_output_d10r f, service, port, op end end |
- (Object) generate_op_ctr(f, service, port, op)
100 101 102 103 104 105 106 107 108 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 100 def generate_op_ctr(f, service, port, op) f.in_def :initialize, 'api', 'service', 'port' do f.call :super, 'api', 'service', 'port' f.assignment '@name', op.property_name.attr_name.inspect f.assignment '@operation_name', generate_name(op.type.name) f.assignment '@soap_action', op.type.soap_action.inspect f.literal_array '@requires', get_op_requires(service, port, op) end end |
- (Object) generate_op_input_body(service, port, op, result)
172 173 174 175 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 172 def generate_op_input_body(service, port, op, result) name = service_namer.get_input_body_name service.type, port.type, op.type generate_body service, port, op, op.type.input, name, result end |
- (Object) generate_op_input_header(service, port, op, result)
145 146 147 148 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 145 def generate_op_input_header(service, port, op, result) name = service_namer.get_input_header_name service.type, port.type, op.type generate_header service, port, op, op.type.input, name, result end |
- (Object) generate_op_output_body(service, port, op, result)
177 178 179 180 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 177 def generate_op_output_body(service, port, op, result) name = service_namer.get_output_body_name service.type, port.type, op.type generate_body service, port, op, op.type.output, name, result end |
- (Object) generate_op_output_header(service, port, op, result)
140 141 142 143 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 140 def generate_op_output_header(service, port, op, result) name = service_namer.get_output_header_name service.type, port.type, op.type generate_header service, port, op, op.type.output, name, result end |
- (Object) generate_operation(service, port, op, result)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 6 def generate_operation(service, port, op, result) modules = get_module_names service.name generate_op_input_body service, port, op, result generate_op_input_header service, port, op, result generate_op_output_header service, port, op, result generate_op_output_body service, port, op, result operation_s8r_generator.generate_operation_s8r service, port, op, result operation_d10r_generator.generate_operation_d10r service, port, op, result type_file_for op.name, result do |f| f.requires operation_base.require_path f.in_modules modules do in_classes f, service.name.class_name, port.name.class_name do generate_op_class f, service, port, op end end end end |
- (Object) generate_output_d10r(f, service, port, op)
66 67 68 69 70 71 72 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 66 def generate_output_d10r(f, service, port, op) name = service_namer.get_output_d10r_name(service.type, port.type, op.type).name f.in_def :output_d10r do f.call :super f.statement "@output_d10r ||= #{name}" end end |
- (Object) generate_output_s8r(f, service, port, op)
49 50 51 52 53 54 55 56 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 49 def generate_output_s8r(f, service, port, op) name = service_namer.get_output_s8r_name(service.type, port.type, op.type).name type_directory_name = namer.get_s8r_type_directory_name.name f.in_def :output_s8r do f.call :super f.statement "@output_s8r ||= #{name}.new(#{type_directory_name})" end end |
- (Object) get_op_requires(service, port, op)
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/wsdl_mapper/svc_generation/operation_generator.rb', line 110 def get_op_requires(service, port, op) requires = [] get_header_parts(op.type.input).each do |part| next if WsdlMapper::Dom::BuiltinType.builtin? get_type_name(part.type).name requires << part.name.require_path end get_body_parts(op.type.input).each do |part| next if WsdlMapper::Dom::BuiltinType.builtin? get_type_name(part.type).name requires << part.name.require_path end get_header_parts(op.type.output).each do |part| next if WsdlMapper::Dom::BuiltinType.builtin? get_type_name(part.type).name requires << part.name.require_path end get_body_parts(op.type.output).each do |part| next if WsdlMapper::Dom::BuiltinType.builtin? get_type_name(part.type).name requires << part.name.require_path end requires << namer.get_s8r_type_directory_name.require_path requires << service_namer.get_input_header_name(service.type, port.type, op.type).require_path requires << service_namer.get_input_body_name(service.type, port.type, op.type).require_path requires << service_namer.get_output_header_name(service.type, port.type, op.type).require_path requires << service_namer.get_output_body_name(service.type, port.type, op.type).require_path requires << service_namer.get_input_s8r_name(service.type, port.type, op.type).require_path requires << service_namer.get_input_d10r_name(service.type, port.type, op.type).require_path requires << service_namer.get_output_s8r_name(service.type, port.type, op.type).require_path requires << service_namer.get_output_d10r_name(service.type, port.type, op.type).require_path requires.uniq.map &:inspect end |