Module: Signum

Defined in:
app/components/signum/notification/component.rb,
lib/signum.rb,
lib/signum/engine.rb,
lib/signum/version.rb,
app/models/signum/signal.rb,
lib/signum/configuration.rb,
app/jobs/signum/application_job.rb,
lib/signum/active_record_helpers.rb,
app/models/signum/application_record.rb,
app/helpers/signum/application_helper.rb,
app/mailers/signum/application_mailer.rb,
lib/generators/signum/install_generator.rb,
app/controllers/signum/signal_controller.rb,
app/components/signum/notifications/component.rb,
app/controllers/signum/application_controller.rb,
lib/generators/signum/tailwind_config_generator.rb,
app/components/signum/notification_body/component.rb,
app/components/signum/notification_drawer/component.rb,
app/components/signum/notification_drawer_item/component.rb

Overview

Defined Under Namespace

Modules: ActiveRecordHelpers, ApplicationHelper, Configurable, Generators, Notification, NotificationBody, NotificationDrawer, NotificationDrawerItem, Notifications, Options Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Configuration, Engine, Error, InstallGenerator, Signal, SignalController

Constant Summary collapse

VERSION =
"0.7.8"

Class Method Summary collapse

Class Method Details

.configObject



10
11
12
# File 'lib/signum.rb', line 10

def config
  @config ||= Configuration.new
end

.error(signalable, options) ⇒ Object

Signal about an error



46
47
48
49
50
# File 'lib/signum.rb', line 46

def error(signalable, options)
  return unless signalable

  signal(signalable, options.merge(kind: "error", icon: Signum.config.icons[:error]))
end

.info(signalable, options) ⇒ Object

Signal about something that happened



39
40
41
42
43
# File 'lib/signum.rb', line 39

def info(signalable, options)
  return unless signalable

  signal(signalable, options.merge(kind: "info", icon: Signum.config.icons[:info]))
end

.setup {|config| ... } ⇒ Object

Yields:



14
15
16
17
# File 'lib/signum.rb', line 14

def setup
  @config = Configuration.new
  yield config
end

.signal(signalable_receiver, options) ⇒ Object

Generic notice



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/signum.rb', line 24

def signal(signalable_receiver, options)
  return unless signalable_receiver

  if signalable_receiver.is_a?(Signum.config.user_model_name.constantize)
    signalable_receiver.signals.create!(options)

  elsif signalable_receiver.respond_to?(:each)
    signalable_receiver.each { |signalable| signal(signalable, options) }
    nil
  else
    Signal.create!(options.merge(key: signalable_receiver.to_s))
  end
end

.success(signalable, options) ⇒ Object

Signal about something that went sucessfully



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

def success(signalable, options)
  return unless signalable

  signal(signalable, options.merge(kind: "success", icon: Signum.config.icons[:success]))
end

.warning(signalable, options) ⇒ Object

Signal about something that could go wrong



60
61
62
63
64
# File 'lib/signum.rb', line 60

def warning(signalable, options)
  return unless signalable

  signal(signalable, options.merge(kind: "warning", icon: Signum.config.icons[:warning]))
end