Class: Softlayer::Generator::Service
- Inherits:
-
Object
- Object
- Softlayer::Generator::Service
- Defined in:
- lib/softlayer/generator/service.rb
Defined Under Namespace
Classes: UnknownMessage
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #document_method_params(name) ⇒ Object
- #document_method_response(name) ⇒ Object
- #document_methods ⇒ Object
-
#initialize(name) ⇒ Service
constructor
A new instance of Service.
- #message_needs_id?(message) ⇒ Boolean
- #process_method_type(type) ⇒ Object
- #representation_hash ⇒ Object
Constructor Details
#initialize(name) ⇒ Service
Returns a new instance of Service.
6 7 8 9 |
# File 'lib/softlayer/generator/service.rb', line 6 def initialize(name) @name = name load_data_file end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/softlayer/generator/service.rb', line 4 def name @name end |
Instance Method Details
#document_method_params(name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/softlayer/generator/service.rb', line 16 def document_method_params(name) return nil if @document.nil? methods = [] = @document.parser.sections["message"].select do |x| x.attributes["name"].value == Converter.(name) end # raise UnknownMessage.new("#{name} has no message") if messages.empty? return [] if .nil? or .empty? # get parameters for message .first.css("part").each do |param| method_type = param["type"] method_type = process_method_type(method_type) if method_type.match(/\Atns:/) methods << {name: param["name"].underscore, type: Converter.type(method_type)} end methods end |
#document_method_response(name) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/softlayer/generator/service.rb', line 45 def document_method_response(name) return nil if @document.nil? = Converter.(name)+"Response" = @document.parser.sections["message"].select do |x| x.attributes["name"].value == end return nil if .empty? return_type = .first.css("part")[0]["type"] Converter.type(return_type) end |
#document_methods ⇒ Object
11 12 13 14 |
# File 'lib/softlayer/generator/service.rb', line 11 def document_methods return nil if @document.nil? @document.soap_actions end |
#message_needs_id?(message) ⇒ Boolean
58 59 60 61 62 63 64 65 66 |
# File 'lib/softlayer/generator/service.rb', line 58 def () return nil if @document.nil? section = @document.parser.sections["binding"].first needs_id = false section.css("operation[name=#{Converter.()}] input").children.each do |header| needs_id = true if header["message"] == "tns:#{@name}InitParametersHeader" end needs_id end |
#process_method_type(type) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/softlayer/generator/service.rb', line 35 def process_method_type(type) return nil if @document.nil? type.sub!('tns:', '') object = @document.parser.sections["types"].first.css("[name='#{type}']").first return type if object.nil? object_type = object.children[1].attributes["base"].value object_type if object_type # type end |
#representation_hash ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/softlayer/generator/service.rb', line 68 def representation_hash return nil if @document.nil? rep = {} document_methods.each do |method| method_scope = :class method_scope = :instance if (method) rep[method] = { input: document_method_params(method), return: document_method_response(method), method_scope: method_scope } end rep end |