Module: SgtnClient::TranslationLoader::SingleLoader

Defined in:
lib/sgtn-client/loader/single_loader.rb

Instance Method Summary collapse

Instance Method Details

#available_bundles(sync: true) ⇒ Object



13
14
15
16
17
# File 'lib/sgtn-client/loader/single_loader.rb', line 13

def available_bundles(sync: true)
  SgtnClient.logger.debug { "[#{__FILE__}][#{__callee__}]" }

  do_single_load(CONSTS::AVAILABLE_BUNDLES_KEY, sync) { super() }
end

#initialize(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sgtn-client/loader/single_loader.rb', line 19

def initialize(*args)
  none_alive = proc { |_, thread| thread.nil? || thread.alive? == false }
  creator = proc do |id, &block|
    Thread.new do
      SgtnClient.logger.debug { "start single loading #{id}" }
      begin
        block.call
      ensure
        # delete thread from hash after finish
        @single_loader.remove_object(id)
      end
    end
  end

  @single_loader = SingleOperation.new(none_alive, &creator)

  super
end

#load_bundle(component, locale, sync: true) ⇒ Object



7
8
9
10
11
# File 'lib/sgtn-client/loader/single_loader.rb', line 7

def load_bundle(component, locale, sync: true)
  SgtnClient.logger.debug { "[#{__FILE__}][#{__callee__}] component=#{component}, locale=#{locale}" }

  do_single_load(Common::BundleID.new(component, locale), sync) { super(component, locale) }
end