Class: RailsDrips::Configuration
- Inherits:
-
Object
- Object
- RailsDrips::Configuration
- Defined in:
- lib/rails_drips/configuration.rb
Instance Attribute Summary collapse
-
#admin_authenticator ⇒ Object
Returns the value of attribute admin_authenticator.
-
#admin_authorizer ⇒ Object
Returns the value of attribute admin_authorizer.
-
#admin_enabled ⇒ Object
Returns the value of attribute admin_enabled.
-
#current_actor_resolver ⇒ Object
Returns the value of attribute current_actor_resolver.
-
#delivery_job_class ⇒ Object
Returns the value of attribute delivery_job_class.
-
#delivery_queue_name ⇒ Object
Returns the value of attribute delivery_queue_name.
-
#eligibility_evaluator ⇒ Object
Returns the value of attribute eligibility_evaluator.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mailers ⇒ Object
readonly
Returns the value of attribute mailers.
-
#preference_evaluator ⇒ Object
Returns the value of attribute preference_evaluator.
-
#queue_inventory ⇒ Object
Returns the value of attribute queue_inventory.
-
#recipient_email_resolver ⇒ Object
Returns the value of attribute recipient_email_resolver.
-
#recipient_label_resolver ⇒ Object
Returns the value of attribute recipient_label_resolver.
-
#snapshot_authorizer ⇒ Object
Returns the value of attribute snapshot_authorizer.
-
#time_source ⇒ Object
Returns the value of attribute time_source.
-
#transport_metadata_hook ⇒ Object
Returns the value of attribute transport_metadata_hook.
Instance Method Summary collapse
- #current_time ⇒ Object
- #delivery_job ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #recipient_email(recipient) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rails_drips/configuration.rb', line 22 def initialize @delivery_queue_name = :default @delivery_job_class = -> { RailsDrips::DeliveryJob } @eligibility_evaluator = ->(**) { true } @logger = defined?(Rails) ? Rails.logger : nil @admin_enabled = false @admin_authenticator = nil @admin_authorizer = nil @preference_evaluator = ->(**) { true } @queue_inventory = nil @recipient_email_resolver = method(:default_recipient_email) @recipient_label_resolver = ->(recipient) { recipient.respond_to?(:name) ? recipient.name : "#{recipient.class.name} ##{recipient.id}" } @current_actor_resolver = ->(_controller) { nil } @snapshot_authorizer = ->(**) { false } @time_source = -> { Time.current } @transport_metadata_hook = ->(message:, **) { } @mailers = MailRegistry.new end |
Instance Attribute Details
#admin_authenticator ⇒ Object
Returns the value of attribute admin_authenticator.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def admin_authenticator @admin_authenticator end |
#admin_authorizer ⇒ Object
Returns the value of attribute admin_authorizer.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def @admin_authorizer end |
#admin_enabled ⇒ Object
Returns the value of attribute admin_enabled.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def admin_enabled @admin_enabled end |
#current_actor_resolver ⇒ Object
Returns the value of attribute current_actor_resolver.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def current_actor_resolver @current_actor_resolver end |
#delivery_job_class ⇒ Object
Returns the value of attribute delivery_job_class.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def delivery_job_class @delivery_job_class end |
#delivery_queue_name ⇒ Object
Returns the value of attribute delivery_queue_name.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def delivery_queue_name @delivery_queue_name end |
#eligibility_evaluator ⇒ Object
Returns the value of attribute eligibility_evaluator.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def eligibility_evaluator @eligibility_evaluator end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def logger @logger end |
#mailers ⇒ Object (readonly)
Returns the value of attribute mailers.
20 21 22 |
# File 'lib/rails_drips/configuration.rb', line 20 def mailers @mailers end |
#preference_evaluator ⇒ Object
Returns the value of attribute preference_evaluator.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def preference_evaluator @preference_evaluator end |
#queue_inventory ⇒ Object
Returns the value of attribute queue_inventory.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def queue_inventory @queue_inventory end |
#recipient_email_resolver ⇒ Object
Returns the value of attribute recipient_email_resolver.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def recipient_email_resolver @recipient_email_resolver end |
#recipient_label_resolver ⇒ Object
Returns the value of attribute recipient_label_resolver.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def recipient_label_resolver @recipient_label_resolver end |
#snapshot_authorizer ⇒ Object
Returns the value of attribute snapshot_authorizer.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def @snapshot_authorizer end |
#time_source ⇒ Object
Returns the value of attribute time_source.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def time_source @time_source end |
#transport_metadata_hook ⇒ Object
Returns the value of attribute transport_metadata_hook.
5 6 7 |
# File 'lib/rails_drips/configuration.rb', line 5 def @transport_metadata_hook end |
Instance Method Details
#current_time ⇒ Object
45 46 47 |
# File 'lib/rails_drips/configuration.rb', line 45 def current_time time_source.call end |
#delivery_job ⇒ Object
41 42 43 |
# File 'lib/rails_drips/configuration.rb', line 41 def delivery_job delivery_job_class.respond_to?(:call) ? delivery_job_class.call : delivery_job_class end |
#recipient_email(recipient) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/rails_drips/configuration.rb', line 49 def recipient_email(recipient) value = recipient_email_resolver.call(recipient).to_s.strip return value unless value.empty? raise RecipientEmailMissing, "No email address could be resolved for #{recipient.class.name}" end |