Module: Angus::SDoc::DefinitionsUtils
- Defined in:
- lib/angus/definitions_utils.rb
Class Method Summary collapse
-
.include_representation(name, representations, into) ⇒ Object
Inserts a representation and its children into a destination.
-
.slice(definition, operation_names) ⇒ Hash
Builds a new definition hash based on the given operation names.
Class Method Details
.include_representation(name, representations, into) ⇒ Object
Note:
The purpose of this method is to be used as an utility method from a method which selects a subset of representations.
Inserts a representation and its children into a destination.
60 61 62 63 64 65 66 67 68 |
# File 'lib/angus/definitions_utils.rb', line 60 def self.include_representation(name, representations, into) if representation = representations[name] into[name] = representation representation.each do |field| field_type = field['type'] || field['elements_type'] include_representation(field_type, representations, into) end end end |
.slice(definition, operation_names) ⇒ Hash
TODO:
Explain better this method. Needs refactor?
Builds a new definition hash based on the given operation names.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/angus/definitions_utils.rb', line 12 def self.slice(definition, operation_names) result = { :operations => {}, :representations => {}, :messages => {} } result[:service] = definition['service'] representations = Set.new = Set.new definition['operations'].each do |code_name, operation| if operation_names.include?(code_name) result[:operations][code_name] = operation types = (operation['response'] || []).map do |element| element['type'] || element['elements_type'] end representations += types += (operation['messages'] || []).map do || ['key'] end end end representations.each do |name| include_representation(name, definition['representations'], result[:representations]) end .each do |key| result[:messages][key] = definition['messages'][key] end result end |