Class: Zm::Client::MountPointsBuilder

Inherits:
Base::ObjectsBuilder show all
Defined in:
lib/zm/client/mountpoint/mountpoints_builder.rb

Overview

class factory [mountpoints]

Instance Method Summary collapse

Methods inherited from Base::ObjectsBuilder

#ids

Constructor Details

#initialize(parent, json) ⇒ MountPointsBuilder

Returns a new instance of MountPointsBuilder.



7
8
9
10
11
12
# File 'lib/zm/client/mountpoint/mountpoints_builder.rb', line 7

def initialize(parent, json)
  super(parent, json)
  @key_link = :link
  @key_folder = :folder
  @list = []
end

Instance Method Details

#construct_tree(json_folders) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/zm/client/mountpoint/mountpoints_builder.rb', line 22

def construct_tree(json_folders)
  json_folders.each do |json_folder|
    if json_folder[@key_link].is_a?(Array)
      @list += json_folder[@key_link].map do |json_link|
        MountpointJsnsInitializer.create(@parent, json_link)
      end
    end

    next if json_folder[@key_folder].nil? || json_folder[@key_folder].empty?

    construct_tree(json_folder[@key_folder])
  end
end

#makeObject



14
15
16
17
18
19
20
# File 'lib/zm/client/mountpoint/mountpoints_builder.rb', line 14

def make
  root = @json[:GetFolderResponse][@key_folder]

  construct_tree(root)

  @list
end