Class: ExceptionNotifier::AsanaNotifier

Inherits:
BaseNotifier
  • Object
show all
Includes:
AsanaExceptionNotifier::ApplicationHelper
Defined in:
lib/asana_exception_notifier/classes/asana.rb

Overview

module that is used for formatting numbers using metrics

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AsanaExceptionNotifier::ApplicationHelper

add_files_to_zip, compress_files, create_archive, create_upload_file_part, default_template_path, ensure_eventmachine_running, escape, execute_with_rescue, extract_body, file_upload_request_options, force_utf8_encoding, get_extension_and_name_from_file, get_hash_rows, get_multi_request_values, get_response_from_request, hash_to_html_attributes, link_helper, log_bactrace, log_exception, logger, max_length, mount_table, mount_table_for_hash, multi_request_manager, multipart_file_upload_details, parse_fieldset_value, permitted_options, register_em_error_handler, rescue_interrupt, root, run_em_reactor, set_fieldset_key, setup_em_options, show_hash_content, split_archive, tempfile_details, template_dir, template_path_exist

Constructor Details

#initialize(options) ⇒ AsanaNotifier

Returns a new instance of AsanaNotifier.



15
16
17
18
19
20
21
22
# File 'lib/asana_exception_notifier/classes/asana.rb', line 15

def initialize(options)
  execute_with_rescue do
    super
    @initial_options = options.symbolize_keys
    options = @initial_options.reject { |_key, value| value.blank? }
    parse_options(options)
  end
end

Instance Attribute Details

#default_optionsObject (readonly)

the base url to which the API will connect for fetching information about gems



13
14
15
# File 'lib/asana_exception_notifier/classes/asana.rb', line 13

def default_options
  @default_options
end

#initial_optionsObject (readonly)

the base url to which the API will connect for fetching information about gems



13
14
15
# File 'lib/asana_exception_notifier/classes/asana.rb', line 13

def initial_options
  @initial_options
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/asana_exception_notifier/classes/asana.rb', line 34

def active?
  @default_options.fetch(:asana_api_key, nil).present? && @default_options.fetch(:workspace, nil).present?
end

#call(exception, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/asana_exception_notifier/classes/asana.rb', line 24

def call(exception, options = {})
  execute_with_rescue do
    ensure_eventmachine_running do
      EM::HttpRequest.use AsanaExceptionNotifier::Request::Middleware if ENV['DEBUG_ASANA_EXCEPTION_NOTIFIER']
      error_page = AsanaExceptionNotifier::ErrorPage.new(template_path, exception, options)
      create_asana_task(error_page) if active?
    end
  end
end