Module: UserNotification
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern
- Defined in:
- lib/user_notification.rb,
lib/user_notification/common.rb,
lib/user_notification/config.rb,
lib/user_notification/version.rb,
lib/user_notification/activity.rb,
lib/generators/user_notification.rb,
lib/user_notification/renderable.rb,
lib/user_notification/actions/update.rb,
lib/user_notification/models/adapter.rb,
lib/user_notification/models/activist.rb,
lib/user_notification/actions/creation.rb,
lib/user_notification/models/notifiable.rb,
lib/user_notification/actions/destruction.rb,
lib/user_notification/models/notification.rb,
lib/user_notification/orm/mongoid/adapter.rb,
lib/user_notification/roles/deactivatable.rb,
lib/user_notification/orm/mongoid/activist.rb,
lib/user_notification/utility/view_helpers.rb,
lib/user_notification/orm/mongoid/notifiable.rb,
lib/user_notification/orm/mongo_mapper/adapter.rb,
lib/user_notification/orm/mongoid/notification.rb,
lib/user_notification/roles/acts_as_notifiable.rb,
lib/user_notification/utility/store_controller.rb,
lib/user_notification/orm/active_record/adapter.rb,
lib/user_notification/orm/mongo_mapper/activist.rb,
lib/user_notification/orm/active_record/activist.rb,
lib/user_notification/orm/mongo_mapper/notifiable.rb,
lib/user_notification/orm/active_record/notifiable.rb,
lib/user_notification/orm/mongo_mapper/notification.rb,
lib/user_notification/orm/active_record/notification.rb,
lib/generators/user_notification/migration/migration_generator.rb,
lib/generators/user_notification/notification/notification_generator.rb
Overview
Provides a shortcut from views to the rendering method.
Defined Under Namespace
Modules: Activist, ActsAsNotifiable, Common, Creation, Deactivatable, Destruction, Generators, Model, Notifiable, ORM, Renderable, StoreController, Update, ViewHelpers Classes: Adapter, Config, NoKeyProvided, Notification
Constant Summary collapse
- VERSION =
A constant with gem’s version
'0.0.2'
- Finalizer =
Lambda called after the thread is destroyed.
lambda { |id| @@controllers.delete id }
- @@controllers =
Hash.new
Class Method Summary collapse
-
.config ⇒ Object
Returns UserNotification’s configuration object.
-
.enabled=(value) ⇒ Object
Switches UserNotification on or off.
-
.enabled? ⇒ Boolean
Returns ‘true` if UserNotification is on, `false` otherwise.
-
.get_controller ⇒ Object
Getter for accessing the controller instance.
-
.inherit_orm(model = "Notification") ⇒ Object
Method used to choose which ORM to load when UserNotification::Notification class is being autoloaded.
-
.resolve_value(context, thing) ⇒ Object
Used to smartly transform value from metadata to data.
-
.set_controller(controller) ⇒ Object
Setter for remembering controller instance.
Class Method Details
.config ⇒ Object
Returns UserNotification’s configuration object.
43 44 45 |
# File 'lib/user_notification.rb', line 43 def self.config @@config ||= UserNotification::Config.instance end |
.enabled=(value) ⇒ Object
Switches UserNotification on or off.
29 30 31 |
# File 'lib/user_notification.rb', line 29 def self.enabled=(value) UserNotification.config.enabled = value end |
.enabled? ⇒ Boolean
Returns ‘true` if UserNotification is on, `false` otherwise. Enabled by default.
37 38 39 |
# File 'lib/user_notification.rb', line 37 def self.enabled? !!UserNotification.config.enabled end |
.get_controller ⇒ Object
Getter for accessing the controller instance
19 20 21 |
# File 'lib/user_notification/utility/store_controller.rb', line 19 def get_controller @@controllers[Thread.current.object_id] end |
.inherit_orm(model = "Notification") ⇒ Object
Method used to choose which ORM to load when UserNotification::Notification class is being autoloaded
49 50 51 52 53 |
# File 'lib/user_notification.rb', line 49 def self.inherit_orm(model="Notification") orm = UserNotification.config.orm require "user_notification/orm/#{orm.to_s}" "UserNotification::ORM::#{orm.to_s.classify}::#{model}".constantize end |
.resolve_value(context, thing) ⇒ Object
Used to smartly transform value from metadata to data. Accepts Symbols, which it will send against context. Accepts Procs, which it will execute with controller and context.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/user_notification/common.rb', line 9 def self.resolve_value(context, thing) case thing when Symbol context.__send__(thing) when Proc thing.call(UserNotification.get_controller, context) else thing end end |
.set_controller(controller) ⇒ Object
Setter for remembering controller instance
11 12 13 14 15 16 |
# File 'lib/user_notification/utility/store_controller.rb', line 11 def set_controller(controller) unless @@controllers.has_key?(Thread.current.object_id) ObjectSpace.define_finalizer Thread.current, Finalizer end if RUBY_VERSION != "1.9.3" @@controllers[Thread.current.object_id] = controller end |