Class: Agave::Local::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/agave/local/loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, preview_mode = false) ⇒ Loader

Returns a new instance of Loader.



13
14
15
16
17
18
# File 'lib/agave/local/loader.rb', line 13

def initialize(client, preview_mode = false)
  @client = client
  @preview_mode = preview_mode
  @entities_repo = EntitiesRepo.new
  @items_repo = ItemsRepo.new(@entities_repo)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/agave/local/loader.rb', line 8

def client
  @client
end

#entities_repoObject (readonly)

Returns the value of attribute entities_repo.



9
10
11
# File 'lib/agave/local/loader.rb', line 9

def entities_repo
  @entities_repo
end

#items_repoObject (readonly)

Returns the value of attribute items_repo.



10
11
12
# File 'lib/agave/local/loader.rb', line 10

def items_repo
  @items_repo
end

#preview_modeObject (readonly)

Returns the value of attribute preview_mode.



11
12
13
# File 'lib/agave/local/loader.rb', line 11

def preview_mode
  @preview_mode
end

Instance Method Details

#loadObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/agave/local/loader.rb', line 20

def load
  threads = [
    Thread.new { Thread.current[:output] = site },
    Thread.new { Thread.current[:output] = all_items },
    Thread.new { Thread.current[:output] = all_uploads }
  ]

  results = threads.map do |t|
    t.join
    t[:output]
  end

  @entities_repo = EntitiesRepo.new(*results)
  @items_repo = ItemsRepo.new(@entities_repo)
end