Module: ActivityNotification

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Defined in:
lib/activity_notification/rails.rb,
lib/activity_notification.rb,
lib/activity_notification/common.rb,
lib/activity_notification/config.rb,
lib/activity_notification/version.rb,
lib/activity_notification/renderable.rb,
lib/activity_notification/models/target.rb,
lib/activity_notification/mailers/helpers.rb,
lib/activity_notification/models/notifier.rb,
lib/activity_notification/models/notifiable.rb,
lib/activity_notification/models/notification.rb,
lib/activity_notification/helpers/view_helpers.rb,
lib/activity_notification/roles/acts_as_target.rb,
lib/activity_notification/apis/notification_api.rb,
lib/activity_notification/roles/acts_as_notifiable.rb,
lib/generators/activity_notification/views_generator.rb,
lib/activity_notification/helpers/polymorphic_helpers.rb,
lib/activity_notification/controllers/store_controller.rb,
lib/generators/activity_notification/install_generator.rb,
lib/generators/activity_notification/controllers_generator.rb,
app/controllers/activity_notification/notifications_controller.rb,
lib/generators/activity_notification/migration/migration_generator.rb,
lib/generators/activity_notification/notification/notification_generator.rb,
app/controllers/activity_notification/notifications_with_devise_controller.rb

Overview

Provides a shortcut from views to the rendering method.

Defined Under Namespace

Modules: ActsAsNotifiable, ActsAsTarget, Common, Generators, Mailers, Notifiable, NotificationApi, Notifier, PolymorphicHelpers, Renderable, StoreController, Target, ViewHelpers Classes: Config, Engine, Mailer, Notification, NotificationsController, NotificationsWithDeviseController

Constant Summary collapse

VERSION =
"0.0.8"

Class Method Summary collapse

Class Method Details

.config ⇒ Object

Returns ActivityNotification's configuration object.



27
28
29
# File 'lib/activity_notification.rb', line 27

def self.config
  @config ||= ActivityNotification::Config.new
end

.configure {|config| ... } ⇒ Object

Lets you set global configuration options.

All available options and their defaults are in the example below:

Examples:

Initializer for Rails

ActivityNotification.configure do |config|
  config.enabled       = false
  config.table_name    = "notifications"
  ...
end

Yields:



40
41
42
# File 'lib/activity_notification.rb', line 40

def self.configure(&block)
  yield(config) if block_given?
end

.get_controller ⇒ Object

Getter for accessing the controller instance



9
10
11
# File 'lib/activity_notification/controllers/store_controller.rb', line 9

def get_controller
  Thread.current[:activity_notification_controller]
end

.resolve_value(context, thing, *args) ⇒ Object

Used to transform value from metadata to data. Accepts Symbols, which it will send against context. Accepts Procs, which it will execute with controller and context. Both Symbols and Procs will be passed arguments of this method.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/activity_notification/common.rb', line 7

def self.resolve_value(context, thing, *args)
  case thing
  when Symbol
    begin
      context.__send__(thing, *args)
    rescue ArgumentError => e
      context.__send__(thing)
    end
  when Proc
    begin
      thing.call(ActivityNotification.get_controller, context, *args)
    rescue ArgumentError => e
      thing.call(ActivityNotification.get_controller, context)
    end
  when Hash
    thing.dup.tap do |hash|
      hash.each do |key, value|
        hash[key] = ActivityNotification.resolve_value(context, value, *args)
      end
    end
  else
    thing
  end
end

.set_controller(controller) ⇒ Object

Setter for remembering controller instance



4
5
6
# File 'lib/activity_notification/controllers/store_controller.rb', line 4

def set_controller(controller)
  Thread.current[:activity_notification_controller] = controller
end