Sha256: 27ee41a43161c3d2d7b1ede9026e68b1aa9b8039e29b28ad7eaf3e168ca89534

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

module Swagger
  module Attachable
    # @api private
    def attach_parent(parent)
      @parent = parent
      attach_to_children
    end

    # @api private
    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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swagger-core-0.2.0 lib/swagger/attachable.rb