Class: Nuntius::Configuration
- Inherits:
-
Object
- Object
- Nuntius::Configuration
- Defined in:
- lib/nuntius/configuration.rb
Instance Attribute Summary collapse
-
#active_storage_service ⇒ Object
Returns the value of attribute active_storage_service.
-
#add_metadata ⇒ Object
Returns the value of attribute add_metadata.
-
#admin_authentication_module ⇒ Object
Returns the value of attribute admin_authentication_module.
-
#admin_layout ⇒ Object
Returns the value of attribute admin_layout.
-
#allow_custom_events ⇒ Object
Returns the value of attribute allow_custom_events.
-
#base_controller ⇒ Object
Returns the value of attribute base_controller.
-
#base_runner ⇒ Object
Returns the value of attribute base_runner.
- #default_params(transaction_log_entry) ⇒ Object
-
#default_template_scope ⇒ Object
Returns the value of attribute default_template_scope.
- #host(message) ⇒ Object
-
#jobs_queue_name ⇒ Object
Returns the value of attribute jobs_queue_name.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#logger ⇒ Object
logger [Object].
-
#metadata_fields ⇒ Object
Returns the value of attribute metadata_fields.
-
#metadata_humanize(metadata) ⇒ Object
Make the part that is important for visible readable for humans.
-
#providers ⇒ Object
readonly
Returns the value of attribute providers.
-
#transports ⇒ Object
readonly
Returns the value of attribute transports.
-
#visible_scope ⇒ Object
Returns the value of attribute visible_scope.
Instance Method Summary collapse
- #add_nuntiable_class(klass) ⇒ Object
-
#admin_mount_point ⇒ Object
admin_mount_point [String].
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #nuntiable_class_names ⇒ Object
- #provider(provider, transport:, priority: 1, timeout: 0, settings: {}) ⇒ Object
- #transport(transport) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nuntius/configuration.rb', line 10 def initialize @logger = Logger.new(STDOUT) @logger.level = Logger::INFO @base_controller = '::ApplicationController' @base_runner = 'Nuntius::BasicApplicationRunner' @nuntiable_classes = [] @nuntiable_class_names = [] @transports = [] @providers = {} @jobs_queue_name = :message @visible_scope = -> { all } @add_metadata = -> {} @metadata_fields = {} @metadata_humanize = ->(data) { data.inspect } @default_template_scope = ->(_object) { all } @allow_custom_events = false @layout = 'application' @admin_layout = 'application' @active_storage_service = nil end |
Instance Attribute Details
#active_storage_service ⇒ Object
Returns the value of attribute active_storage_service.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def active_storage_service @active_storage_service end |
#add_metadata ⇒ Object
Returns the value of attribute add_metadata.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def @add_metadata end |
#admin_authentication_module ⇒ Object
Returns the value of attribute admin_authentication_module.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def admin_authentication_module @admin_authentication_module end |
#admin_layout ⇒ Object
Returns the value of attribute admin_layout.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def admin_layout @admin_layout end |
#allow_custom_events ⇒ Object
Returns the value of attribute allow_custom_events.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def allow_custom_events @allow_custom_events end |
#base_controller ⇒ Object
Returns the value of attribute base_controller.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def base_controller @base_controller end |
#base_runner ⇒ Object
Returns the value of attribute base_runner.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def base_runner @base_runner end |
#default_params(transaction_log_entry) ⇒ Object
74 75 76 |
# File 'lib/nuntius/configuration.rb', line 74 def default_params(transaction_log_entry) @default_params.is_a?(Proc) ? instance_exec(transaction_log_entry, &@default_params) : @default_params end |
#default_template_scope ⇒ Object
Returns the value of attribute default_template_scope.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def default_template_scope @default_template_scope end |
#host(message) ⇒ Object
36 37 38 |
# File 'lib/nuntius/configuration.rb', line 36 def host() @host.is_a?(Proc) ? instance_exec(, &@host) : @host end |
#jobs_queue_name ⇒ Object
Returns the value of attribute jobs_queue_name.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def jobs_queue_name @jobs_queue_name end |
#layout ⇒ Object
Returns the value of attribute layout.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def layout @layout end |
#logger ⇒ Object
logger [Object].
32 33 34 |
# File 'lib/nuntius/configuration.rb', line 32 def logger @logger.is_a?(Proc) ? instance_exec(&@logger) : @logger end |
#metadata_fields ⇒ Object
Returns the value of attribute metadata_fields.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def @metadata_fields end |
#metadata_humanize(metadata) ⇒ Object
Make the part that is important for visible readable for humans
41 42 43 |
# File 'lib/nuntius/configuration.rb', line 41 def () @metadata_humanize.is_a?(Proc) ? instance_exec(, &@metadata_humanize) : @metadata_humanize end |
#providers ⇒ Object (readonly)
Returns the value of attribute providers.
8 9 10 |
# File 'lib/nuntius/configuration.rb', line 8 def providers @providers end |
#transports ⇒ Object (readonly)
Returns the value of attribute transports.
8 9 10 |
# File 'lib/nuntius/configuration.rb', line 8 def transports @transports end |
#visible_scope ⇒ Object
Returns the value of attribute visible_scope.
5 6 7 |
# File 'lib/nuntius/configuration.rb', line 5 def visible_scope @visible_scope end |
Instance Method Details
#add_nuntiable_class(klass) ⇒ Object
50 51 52 53 |
# File 'lib/nuntius/configuration.rb', line 50 def add_nuntiable_class(klass) @nuntiable_class_names = [] @nuntiable_classes << klass.to_s unless @nuntiable_classes.include?(klass.to_s) end |
#admin_mount_point ⇒ Object
admin_mount_point [String].
46 47 48 |
# File 'lib/nuntius/configuration.rb', line 46 def admin_mount_point @admin_mount_point ||= '/nuntius' end |
#nuntiable_class_names ⇒ Object
55 56 57 58 59 |
# File 'lib/nuntius/configuration.rb', line 55 def nuntiable_class_names return @nuntiable_class_names if @nuntiable_class_names.present? compile_nuntiable_class_names! end |
#provider(provider, transport:, priority: 1, timeout: 0, settings: {}) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/nuntius/configuration.rb', line 61 def provider(provider, transport:, priority: 1, timeout: 0, settings: {}) if @transports.include? transport @providers[transport.to_sym] ||= [] @providers[transport.to_sym].push(provider: provider, priority: priority, timeout: timeout, settings: settings) else Nuntius.logger.warn "provider #{provider} not enabled as transport #{transport} is not enabled" end end |
#transport(transport) ⇒ Object
70 71 72 |
# File 'lib/nuntius/configuration.rb', line 70 def transport(transport) @transports.push(transport) if transport end |