Class: Swagger::Blocks::Nodes::AllOfNode

Inherits:
Swagger::Blocks::Node show all
Defined in:
lib/swagger/blocks/nodes/all_of_node.rb

Instance Attribute Summary

Attributes inherited from Swagger::Blocks::Node

#name, #version

Instance Method Summary collapse

Methods inherited from Swagger::Blocks::Node

call, #is_swagger_2_0?, #keys

Instance Method Details

#as_jsonObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 5

def as_json
  result = []

  self.data.each do |value|
    if value.is_a?(Node)
      result << value.as_json
    elsif value.is_a?(Array)
      r = []
      value.each { |v| r << (v.respond_to?(:as_json) ? v.as_json : v) }
      result << r
    elsif is_swagger_2_0? && value.is_a?(Hash)
      r = {}
      value.each_pair {|k, v| r[k] = (v.respond_to?(:as_json) ? v.as_json : v) }
      result << r
    else
      result = value
    end
  end
  return result if !name
  # If 'name' is given to this node, wrap the data with a root element with the given name.
  {name => result}
end

#dataObject



28
29
30
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 28

def data
  @data ||= []
end

#key(key, value) ⇒ Object

Raises:



32
33
34
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 32

def key(key, value)
  raise NotSupportedError
end

#schema(inline_keys = nil, &block) ⇒ Object



36
37
38
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 36

def schema(inline_keys = nil, &block)
  data << Swagger::Blocks::Nodes::SchemaNode.call(version: version, inline_keys: inline_keys, &block)
end