Class: Nuntius::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/nuntius/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_serviceObject

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_metadataObject

Returns the value of attribute add_metadata.



5
6
7
# File 'lib/nuntius/configuration.rb', line 5

def 
  @add_metadata
end

#admin_authentication_moduleObject

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_layoutObject

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_eventsObject

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_controllerObject

Returns the value of attribute base_controller.



5
6
7
# File 'lib/nuntius/configuration.rb', line 5

def base_controller
  @base_controller
end

#base_runnerObject

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_scopeObject

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(message)
  @host.is_a?(Proc) ? instance_exec(message, &@host) : @host
end

#jobs_queue_nameObject

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

#layoutObject

Returns the value of attribute layout.



5
6
7
# File 'lib/nuntius/configuration.rb', line 5

def layout
  @layout
end

#loggerObject

logger [Object].



32
33
34
# File 'lib/nuntius/configuration.rb', line 32

def logger
  @logger.is_a?(Proc) ? instance_exec(&@logger) : @logger
end

#metadata_fieldsObject

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

#providersObject (readonly)

Returns the value of attribute providers.



8
9
10
# File 'lib/nuntius/configuration.rb', line 8

def providers
  @providers
end

#transportsObject (readonly)

Returns the value of attribute transports.



8
9
10
# File 'lib/nuntius/configuration.rb', line 8

def transports
  @transports
end

#visible_scopeObject

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_pointObject

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_namesObject



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