class Angus::SDoc::Definitions::Service
Attributes
@!attribute [rw] code_name
@return [String] the service code name is a unique identifier. It has to be human-readable and a valid literal identifier.
@!attribute [rw] glossary
@return [Glossary] the glossary of the service.
@!attribute [rw] messages
@return [Hash<String, Message>] the messages associated with the service.
@!attribute [rw] name
@return [String] the name of the service.
@!attribute [rw] operations
@return [Set<Operation>] the operations of the service.
@!attribute [rw] proxy_operations
@return [Set<ProxyOperation>] the proxy operations of the service.
@!attribute [rw] representations
@return [Set<Representation>] the representations of the service.
@!attribute [rw] version
@return [String] the version of the service.
Public Class Methods
# File lib/angus/definitions/service.rb, line 38 def initialize @messages = {} @operations = Set.new @proxy_operations = Set.new @representations = Set.new @glossary = Angus::SDoc::Definitions::Glossary.new end
Public Instance Methods
Merge the following definitions:
- Operations. - Representations. - Messages.
@note This method does not merge glossary terms.
@param [Service] other The service to be merged.
# File lib/angus/definitions/service.rb, line 72 def merge(other) self.operations.merge!(other.operations) self.representations += other.representations self.messages.merge!(other.messages) end
Returns the message that matches the given key and level.
This method searches for messages in all the operations and returns the first message that matches.
@param [#to_s] key The key of the message. @param [String] level The level of the message
Possible values are the *_LEVEL constants from {Message}
@return [Message] the message or nil if no one matches.
# File lib/angus/definitions/service.rb, line 56 def message(key, level = nil) message = self.messages.find do |message_key, message| message_key == key && (!level || message.level.downcase == level) end message.last if message end
Returns the operation definition that matches with the given operation name.
@param operation_code_name The operation code name.
@return [Operation] The operation.
# File lib/angus/definitions/service.rb, line 84 def operation_definition(namespace, operation_code_name) @operations[namespace].find { |operation| operation.code_name == operation_code_name } end
Returns the proxy operations for a given service. @todo Does it receives the service or the service name? @todo Verify if this method is being called by remote-client and if it receives
the service name.
@param service The service name. @return [Array<ProxyOperation>] The proxy operations.
# File lib/angus/definitions/service.rb, line 94 def proxy_operations_for(service) self.proxy_operations.select do |op| op.service_name == service end end
Returns a hash with the representations. @example
{ key => rollback_payment_multi, value => {representation} }
@return [Hash<String, Representation>] The representation hash.
# File lib/angus/definitions/service.rb, line 107 def representations_hash hash = {} @representations.each do |representation| hash[representation.name] = representation end hash end