Module: Swagger::Attachable

Included in:
DefinitionSection, Schema
Defined in:
lib/swagger/attachable.rb

Instance Method Summary collapse

Instance Method Details

#attach_parent(parent) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



4
5
6
7
# File 'lib/swagger/attachable.rb', line 4

def attach_parent(parent)
  @parent = parent
  attach_to_children
end

#attach_to_childrenObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/swagger/attachable.rb', line 10

def attach_to_children # rubocop:disable Metrics/MethodLength
  each_value do |v|
    if v.respond_to? :attach_parent
      v.attach_parent self
    elsif v.respond_to? :each_value
      v.each_value do |sv|
        sv.attach_parent self if sv.respond_to? :attach_parent
      end
    elsif v.respond_to? :each
      v.each do |sv|
        sv.attach_parent self if sv.respond_to? :attach_parent
      end
    end
  end
end

#rootObject



26
27
28
29
# File 'lib/swagger/attachable.rb', line 26

def root
  return self if parent.nil?
  parent.root
end