Module: Nuntius

Extended by:
Configurable
Defined in:
app/jobs/nuntius/messenger_job.rb,
lib/nuntius.rb,
lib/nuntius/devise.rb,
lib/nuntius/engine.rb,
lib/nuntius/version.rb,
lib/nuntius/nuntiable.rb,
lib/nuntius/deprecator.rb,
lib/nuntius/i18n_store.rb,
lib/nuntius/life_cycle.rb,
app/models/nuntius/list.rb,
app/models/nuntius/layout.rb,
app/models/nuntius/locale.rb,
lib/nuntius/configuration.rb,
lib/nuntius/state_machine.rb,
app/models/nuntius/message.rb,
app/drops/nuntius/list_drop.rb,
app/models/nuntius/campaign.rb,
app/models/nuntius/template.rb,
lib/nuntius/mail_allow_list.rb,
app/drops/nuntius/layout_drop.rb,
app/models/nuntius/attachment.rb,
app/models/nuntius/subscriber.rb,
app/drops/nuntius/message_drop.rb,
app/tables/nuntius/lists_table.rb,
app/drops/nuntius/campaign_drop.rb,
app/drops/nuntius/template_drop.rb,
app/jobs/nuntius/application_job.rb,
app/tables/nuntius/layouts_table.rb,
app/tables/nuntius/locales_table.rb,
app/drops/nuntius/subscriber_drop.rb,
app/tables/nuntius/messages_table.rb,
app/drops/nuntius/application_drop.rb,
app/jobs/nuntius/purge_message_job.rb,
app/jobs/nuntius/retrieve_mail_job.rb,
app/models/nuntius/inbound_message.rb,
app/tables/nuntius/campaigns_table.rb,
app/tables/nuntius/templates_table.rb,
app/models/nuntius/concerns/yamlify.rb,
app/providers/nuntius/base_provider.rb,
app/tables/nuntius/application_table.rb,
app/tables/nuntius/subscribers_table.rb,
app/transports/nuntius/sms_transport.rb,
app/exceptions/nuntius/base_exception.rb,
app/jobs/nuntius/timebased_events_job.rb,
app/messengers/nuntius/base_messenger.rb,
app/models/nuntius/application_record.rb,
app/transports/nuntius/base_transport.rb,
app/transports/nuntius/mail_transport.rb,
app/transports/nuntius/push_transport.rb,
app/helpers/nuntius/application_helper.rb,
app/jobs/nuntius/transport_refresh_job.rb,
app/transports/nuntius/slack_transport.rb,
app/transports/nuntius/teams_transport.rb,
app/transports/nuntius/voice_transport.rb,
app/jobs/nuntius/transport_delivery_job.rb,
app/messengers/nuntius/custom_messenger.rb,
app/providers/nuntius/smtp_mail_provider.rb,
app/services/nuntius/application_service.rb,
lib/generators/nuntius/install_generator.rb,
app/providers/nuntius/twilio_sms_provider.rb,
app/message_boxes/nuntius/base_message_box.rb,
app/providers/nuntius/slack_slack_provider.rb,
app/providers/nuntius/teams_teams_provider.rb,
app/tables/nuntius/campaign_messages_table.rb,
app/controllers/nuntius/feedback_controller.rb,
app/controllers/nuntius/messages_controller.rb,
app/models/nuntius/concerns/metadata_scoped.rb,
app/providers/nuntius/apnotic_push_provider.rb,
app/providers/nuntius/houston_push_provider.rb,
app/providers/nuntius/smstools_sms_provider.rb,
app/providers/nuntius/twilio_voice_provider.rb,
app/controllers/nuntius/callbacks_controller.rb,
app/controllers/nuntius/dashboard_controller.rb,
app/jobs/nuntius/deliver_inbound_message_job.rb,
app/providers/nuntius/firebase_push_provider.rb,
app/controllers/nuntius/api/events_controller.rb,
app/services/nuntius/deliver_campaign_service.rb,
app/controllers/nuntius/admin/lists_controller.rb,
app/controllers/nuntius/application_controller.rb,
app/controllers/nuntius/subscribers_controller.rb,
app/services/nuntius/aws_sns_processor_service.rb,
app/providers/nuntius/message_bird_sms_provider.rb,
app/controllers/nuntius/admin/layouts_controller.rb,
app/controllers/nuntius/admin/locales_controller.rb,
lib/generators/nuntius/tailwind_config_generator.rb,
app/controllers/nuntius/admin/messages_controller.rb,
app/controllers/nuntius/admin/campaigns_controller.rb,
app/controllers/nuntius/admin/templates_controller.rb,
app/exceptions/nuntius/missing_messenger_exception.rb,
app/services/nuntius/retrieve_inbound_mail_service.rb,
app/controllers/nuntius/application_admin_controller.rb,
app/services/nuntius/deliver_inbound_message_service.rb,
app/controllers/nuntius/admin/lists/subscribers_controller.rb,
app/controllers/nuntius/admin/layouts/attachments_controller.rb,
app/controllers/nuntius/inbound_messages/twilio_inbound_smses_controller.rb

Overview

Defined Under Namespace

Modules: ActiveRecordHelpers, ActiveStorageHelpers, Admin, ApplicationHelper, Concerns, Configurable, Devise, Generators, InboundMessages, LifeCycle, Nuntiable, Options, StateMachine Classes: ApnoticPushProvider, ApplicationAdminController, ApplicationController, ApplicationDrop, ApplicationJob, ApplicationRecord, ApplicationService, ApplicationTable, Attachment, AwsSnsProcessorService, BaseException, BaseMessageBox, BaseMessenger, BaseProvider, BaseTransport, CallbacksController, Campaign, CampaignDrop, CampaignMessagesTable, CampaignsTable, Configuration, CustomMessenger, DashboardController, DeliverCampaignService, DeliverInboundMessageJob, DeliverInboundMessageService, Deprecator, Engine, Error, FeedbackController, FirebasePushProvider, HoustonPushProvider, I18nStore, InboundMessage, InstallGenerator, Layout, LayoutDrop, LayoutsTable, List, ListDrop, ListsTable, Locale, LocalesTable, MailAllowList, MailTransport, Message, MessageBirdSmsProvider, MessageDrop, MessagesController, MessagesTable, MessengerJob, MissingMessengerException, PurgeMessageJob, PushTransport, RetrieveInboundMailService, RetrieveMailJob, SlackSlackProvider, SlackTransport, SmsTransport, SmstoolsSmsProvider, SmtpMailProvider, Subscriber, SubscriberDrop, SubscribersController, SubscribersTable, TeamsTeamsProvider, TeamsTransport, Template, TemplateDrop, TemplatesTable, TimebasedEventsJob, TransportDeliveryJob, TransportRefreshJob, TwilioSmsProvider, TwilioVoiceProvider, VoiceTransport

Constant Summary collapse

ROOT_PATH =
Pathname.new(File.join(__dir__, ".."))
VERSION =
"1.3.12"

Instance Attribute Summary

Attributes included from Configurable

#config

Class Method Summary collapse

Methods included from Configurable

configure, reset_config!

Class Method Details

.active_storage_enabled?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/nuntius.rb', line 48

def active_storage_enabled?
  ActiveRecord::Base.connection.table_exists? "active_storage_attachments"
end

.event(event, obj, params = {}) ⇒ Object

Fires an event for use with templates with the object

Nuntius.event(:your_event, car)

When custom events are enabled you can also do the following:

Nuntius.event(‘shipped’, { shipped: { to: ‘[email protected]’, ref: ‘Test-123’} }, attachments: [ { url: ‘example.com’ } ])



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/nuntius.rb', line 31

def event(event, obj, params = {})
  return unless event
  return unless obj.is_a?(Hash) || obj.nuntiable?
  return unless templates?(obj, event)

  params = (Nuntius.config.default_params(event, obj) || {}).merge(params)
  options = params[:options] || {}

  if options[:perform_now] == true
    Nuntius::MessengerJob.perform_now(obj, event.to_s, params)
  else
    job = Nuntius::MessengerJob
    job.set(wait: options[:wait]) if options[:wait]
    job.perform_later(obj, event.to_s, params)
  end
end

.i18n_storeObject



18
19
20
# File 'lib/nuntius.rb', line 18

def i18n_store
  @i18n_store ||= Nuntius::I18nStore.new
end

.templates?(obj, event) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
# File 'lib/nuntius.rb', line 52

def templates?(obj, event)
  Nuntius::Template.where(klass: Nuntius::BaseMessenger.class_names_for(obj),
    event: Nuntius::BaseMessenger.event_name_for(
      obj, event
    )).where(enabled: true).count.positive?
end