Module: PublicActivity
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern
- Defined in:
- lib/public_activity.rb,
lib/public_activity/common.rb,
lib/public_activity/config.rb,
lib/public_activity/testing.rb,
lib/public_activity/version.rb,
lib/public_activity/activity.rb,
lib/generators/public_activity.rb,
lib/public_activity/renderable.rb,
lib/public_activity/roles/tracked.rb,
lib/public_activity/actions/update.rb,
lib/public_activity/models/adapter.rb,
lib/public_activity/models/activist.rb,
lib/public_activity/models/activity.rb,
lib/public_activity/actions/creation.rb,
lib/public_activity/models/trackable.rb,
lib/public_activity/actions/destruction.rb,
lib/public_activity/orm/mongoid/adapter.rb,
lib/public_activity/roles/deactivatable.rb,
lib/public_activity/orm/mongoid/activist.rb,
lib/public_activity/orm/mongoid/activity.rb,
lib/public_activity/utility/view_helpers.rb,
lib/public_activity/orm/mongoid/trackable.rb,
lib/public_activity/orm/mongo_mapper/adapter.rb,
lib/public_activity/utility/store_controller.rb,
lib/public_activity/orm/active_record/adapter.rb,
lib/public_activity/orm/mongo_mapper/activist.rb,
lib/public_activity/orm/mongo_mapper/activity.rb,
lib/public_activity/orm/active_record/activist.rb,
lib/public_activity/orm/active_record/activity.rb,
lib/public_activity/orm/mongo_mapper/trackable.rb,
lib/public_activity/orm/active_record/trackable.rb,
lib/generators/public_activity/migration/migration_generator.rb,
lib/generators/public_activity/migration_upgrade/migration_upgrade_generator.rb
Overview
Provides a shortcut from views to the rendering method.
Defined Under Namespace
Modules: Activist, Common, Creation, Deactivatable, Destruction, Generators, Model, Mysql2, ORM, Renderable, StoreController, Trackable, Tracked, Update, ViewHelpers Classes: Activity, Adapter, Config, NoKeyProvided
Constant Summary collapse
- VERSION =
A constant with gem’s version
'3.0.1'
Class Method Summary collapse
-
.config ⇒ Object
Returns PublicActivity’s configuration object.
-
.enabled=(value) ⇒ Object
Switches PublicActivity on or off.
-
.enabled? ⇒ Boolean
Returns ‘true` if PublicActivity is on, `false` otherwise.
-
.get_controller ⇒ Object
Getter for accessing the controller instance.
-
.inherit_orm(model = 'Activity') ⇒ Object
Method used to choose which ORM to load when PublicActivity::Activity 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.
-
.with_tracking ⇒ Object
Execute the code block with PublicActiviy active.
-
.without_tracking ⇒ Object
Execute the code block with PublicActiviy deactive.
Class Method Details
.config ⇒ Object
Returns PublicActivity’s configuration object.
45 46 47 |
# File 'lib/public_activity.rb', line 45 def self.config @@config ||= PublicActivity::Config.instance end |
.enabled=(value) ⇒ Object
Switches PublicActivity on or off.
31 32 33 |
# File 'lib/public_activity.rb', line 31 def self.enabled=(value) config.enabled(value) end |
.enabled? ⇒ Boolean
Returns ‘true` if PublicActivity is on, `false` otherwise. Enabled by default.
39 40 41 |
# File 'lib/public_activity.rb', line 39 def self.enabled? config.enabled end |
.get_controller ⇒ Object
Getter for accessing the controller instance
11 12 13 |
# File 'lib/public_activity/utility/store_controller.rb', line 11 def get_controller Thread.current[:public_activity_controller] end |
.inherit_orm(model = 'Activity') ⇒ Object
Method used to choose which ORM to load when PublicActivity::Activity class is being autoloaded
51 52 53 54 55 |
# File 'lib/public_activity.rb', line 51 def self.inherit_orm(model = 'Activity') orm = PublicActivity.config.orm require "public_activity/orm/#{orm}" "PublicActivity::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.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/public_activity/common.rb', line 11 def self.resolve_value(context, thing) case thing when Symbol context.__send__(thing) when Proc thing.call(PublicActivity.get_controller, context) else thing end end |
.set_controller(controller) ⇒ Object
Setter for remembering controller instance
6 7 8 |
# File 'lib/public_activity/utility/store_controller.rb', line 6 def set_controller(controller) Thread.current[:public_activity_controller] = controller end |
.with_tracking ⇒ Object
Execute the code block with PublicActiviy active
Example usage:
PublicActivity.with_tracking do
# your test code here
end
16 17 18 19 20 21 22 |
# File 'lib/public_activity/testing.rb', line 16 def self.with_tracking current = PublicActivity.config.enabled PublicActivity.config.enabled(true) yield ensure PublicActivity.config.enabled(current) end |
.without_tracking ⇒ Object
Execute the code block with PublicActiviy deactive
Example usage:
PublicActivity.without_tracking do
# your test code here
end
30 31 32 33 34 35 36 |
# File 'lib/public_activity/testing.rb', line 30 def self.without_tracking current = PublicActivity.enabled? PublicActivity.config.enabled(false) yield ensure PublicActivity.config.enabled(current) end |