class Angus::SDoc::Definitions::Service

Attributes

code_name[RW]

@!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.
glossary[RW]

@!attribute [rw] glossary

@return [Glossary] the glossary of the service.
messages[RW]

@!attribute [rw] messages

@return [Hash<String, Message>] the messages associated with the service.
name[RW]

@!attribute [rw] name

@return [String] the name of the service.
operations[RW]

@!attribute [rw] operations

@return [Set<Operation>] the operations of the service.
proxy_operations[RW]

@!attribute [rw] proxy_operations

@return [Set<ProxyOperation>] the proxy operations of the service.
representations[RW]

@!attribute [rw] representations

@return [Set<Representation>] the representations of the service.
version[RW]

@!attribute [rw] version

@return [String] the version of the service.

Public Class Methods

new() click to toggle source
# 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(other) click to toggle source

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
message(key, level = nil) click to toggle source

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
operation_definition(namespace, operation_code_name) click to toggle source

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
proxy_operations_for(service) click to toggle source

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
representations_hash() click to toggle source

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