Class: Nuntius::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Options

included, #set_defaults!

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/nuntius/configuration.rb', line 56

def initialize
  set_defaults!

  @nuntiable_classes = []
  @nuntiable_class_names = []
  @transports = []
  @providers = {}
  @visible_scope = -> { all }
  @add_metadata = -> {}
  @metadata_fields = {}
  @metadata_humanize = ->(data) { data.inspect }
  @default_template_scope = ->(_object) { all }
  @default_params = {}
end

Instance Attribute Details

#add_metadataObject

Returns the value of attribute add_metadata.



51
52
53
# File 'lib/nuntius/configuration.rb', line 51

def 
  @add_metadata
end

#default_params(event, record) ⇒ Object



100
101
102
# File 'lib/nuntius/configuration.rb', line 100

def default_params(event, record)
  @default_params.is_a?(Proc) ? instance_exec(event, record, &@default_params) : @default_params
end

#default_template_scopeObject

Returns the value of attribute default_template_scope.



51
52
53
# File 'lib/nuntius/configuration.rb', line 51

def default_template_scope
  @default_template_scope
end

#flow_color(template_id) ⇒ Object



104
105
106
# File 'lib/nuntius/configuration.rb', line 104

def flow_color(template_id)
  @flow_color.is_a?(Proc) ? instance_exec(template_id, &@flow_color) : @flow_color
end

#metadata_fieldsObject

Returns the value of attribute metadata_fields.



51
52
53
# File 'lib/nuntius/configuration.rb', line 51

def 
  @metadata_fields
end

#metadata_humanize(metadata) ⇒ Object

Make the part that is important for visible readable for humans



72
73
74
# File 'lib/nuntius/configuration.rb', line 72

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

#providersObject (readonly)

Returns the value of attribute providers.



54
55
56
# File 'lib/nuntius/configuration.rb', line 54

def providers
  @providers
end

#transportsObject (readonly)

Returns the value of attribute transports.



54
55
56
# File 'lib/nuntius/configuration.rb', line 54

def transports
  @transports
end

#visible_scopeObject

Returns the value of attribute visible_scope.



51
52
53
# File 'lib/nuntius/configuration.rb', line 51

def visible_scope
  @visible_scope
end

Instance Method Details

#add_nuntiable_class(klass) ⇒ Object



76
77
78
79
# File 'lib/nuntius/configuration.rb', line 76

def add_nuntiable_class(klass)
  @nuntiable_class_names = []
  @nuntiable_classes << klass.to_s unless @nuntiable_classes.include?(klass.to_s)
end

#nuntiable_class_namesObject



81
82
83
84
85
# File 'lib/nuntius/configuration.rb', line 81

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



87
88
89
90
91
92
93
94
# File 'lib/nuntius/configuration.rb', line 87

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.config.logger.call.warn "provider #{provider} not enabled as transport #{transport} is not enabled"
  end
end

#transport(transport) ⇒ Object



96
97
98
# File 'lib/nuntius/configuration.rb', line 96

def transport(transport)
  @transports.push(transport) if transport
end