class Rox::Core::ConfigurationFetchedInvoker

Public Class Methods

new(user_unhandled_error_invoker) click to toggle source
# File lib/rox/core/configuration/configuration_fetched_invoker.rb, line 6
def initialize(user_unhandled_error_invoker)
  @fetched_handlers = []
  @mutex = Mutex.new
  @user_unhandled_error_invoker = user_unhandled_error_invoker
end

Public Instance Methods

invoke(fetcher_status, creation_date, has_changes) click to toggle source
# File lib/rox/core/configuration/configuration_fetched_invoker.rb, line 12
def invoke(fetcher_status, creation_date, has_changes)
  raise_fetched_event(Rox::Core::ConfigurationFetchedArgs.new(fetcher_status, creation_date, has_changes))
end
invoke_error(error_details) click to toggle source
# File lib/rox/core/configuration/configuration_fetched_invoker.rb, line 16
def invoke_error(error_details)
  raise_fetched_event(Rox::Core::ConfigurationFetchedArgs.error(error_details))
end
raise_fetched_event(args) click to toggle source
# File lib/rox/core/configuration/configuration_fetched_invoker.rb, line 26
def raise_fetched_event(args)
  handlers = []
  @mutex.synchronize do
    handlers = @fetched_handlers.clone
  end

  handlers.each do |handler|
    begin
      handler.call(args)
    rescue StandardError => e
      user_unhandled_error_invoker.invoke(handler, Rox::Core::CONFIGURATION_FETCHED_HANDLER, e)
    end
  end
end
register_fetched_handler(&block) click to toggle source
# File lib/rox/core/configuration/configuration_fetched_invoker.rb, line 20
def register_fetched_handler(&block)
  @mutex.synchronize do
    @fetched_handlers << block
  end
end