activity_hub 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +260 -0
- data/Rakefile +20 -0
- data/lib/generators/public_activity.rb +16 -0
- data/lib/generators/public_activity/migration/migration_generator.rb +19 -0
- data/lib/generators/public_activity/migration_upgrade/migration_upgrade_generator.rb +19 -0
- data/lib/generators/public_activity/migration_upgrade/templates/upgrade.rb +11 -0
- data/lib/public_activity.rb +70 -0
- data/lib/public_activity/actions/creation.rb +19 -0
- data/lib/public_activity/actions/destruction.rb +19 -0
- data/lib/public_activity/actions/update.rb +20 -0
- data/lib/public_activity/activity.rb +8 -0
- data/lib/public_activity/common.rb +363 -0
- data/lib/public_activity/config.rb +102 -0
- data/lib/public_activity/models/activist.rb +11 -0
- data/lib/public_activity/models/activity.rb +6 -0
- data/lib/public_activity/models/adapter.rb +7 -0
- data/lib/public_activity/models/trackable.rb +11 -0
- data/lib/public_activity/orm/active_record.rb +7 -0
- data/lib/public_activity/orm/active_record/activist.rb +35 -0
- data/lib/public_activity/orm/active_record/activity.rb +66 -0
- data/lib/public_activity/orm/active_record/adapter.rb +23 -0
- data/lib/public_activity/orm/active_record/trackable.rb +17 -0
- data/lib/public_activity/orm/mongo_mapper.rb +6 -0
- data/lib/public_activity/orm/mongo_mapper/activist.rb +36 -0
- data/lib/public_activity/orm/mongo_mapper/activity.rb +35 -0
- data/lib/public_activity/orm/mongo_mapper/adapter.rb +19 -0
- data/lib/public_activity/orm/mongo_mapper/trackable.rb +13 -0
- data/lib/public_activity/orm/mongoid.rb +6 -0
- data/lib/public_activity/orm/mongoid/activist.rb +36 -0
- data/lib/public_activity/orm/mongoid/activity.rb +34 -0
- data/lib/public_activity/orm/mongoid/adapter.rb +19 -0
- data/lib/public_activity/orm/mongoid/trackable.rb +13 -0
- data/lib/public_activity/renderable.rb +166 -0
- data/lib/public_activity/roles/deactivatable.rb +44 -0
- data/lib/public_activity/roles/tracked.rb +196 -0
- data/lib/public_activity/testing.rb +37 -0
- data/lib/public_activity/utility/store_controller.rb +32 -0
- data/lib/public_activity/utility/view_helpers.rb +30 -0
- data/lib/public_activity/version.rb +6 -0
- data/test/migrations/001_create_activities.rb +25 -0
- data/test/migrations/002_create_articles.rb +15 -0
- data/test/migrations/003_create_users.rb +12 -0
- data/test/migrations/004_add_nonstandard_to_activities.rb +11 -0
- data/test/migrations_base.rb +7 -0
- data/test/mongo_mapper.yml +4 -0
- data/test/mongoid.yml +6 -0
- data/test/test_activist.rb +58 -0
- data/test/test_activity.rb +89 -0
- data/test/test_common.rb +194 -0
- data/test/test_controller_integration.rb +42 -0
- data/test/test_generators.rb +31 -0
- data/test/test_helper.rb +144 -0
- data/test/test_testing.rb +37 -0
- data/test/test_tracking.rb +385 -0
- data/test/test_view_helpers.rb +38 -0
- data/test/views/custom/_layout.erb +1 -0
- data/test/views/custom/_test.erb +1 -0
- data/test/views/layouts/_activity.erb +1 -0
- data/test/views/public_activity/_test.erb +8 -0
- metadata +295 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 463e1aba9dc9f50fddf18b2686b57ddb1a3d85ae7580b2c3ee87fb2162b3f2fd
|
4
|
+
data.tar.gz: 8544f01f08091445b991813eb03f240ca68817f9b13ea8a9ef3288b3edeebf63
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e2aec02d6f9a434d7b95573e1ff0598b6a539843002a09c5e5cb0f1c7b014efb8572f7ea8e400f2b06ecd2748917326b2a4682d1aef85d581f4c812687829fc0
|
7
|
+
data.tar.gz: 720a2da75369d503bc079a91aad9f8068d17612dd9ae54957fc771fcdddd1c2984708370fdf61a81ab8b17bbcf0bdb0bf2c1481e7870a1de98a87062778bd420
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011-2013 Piotrek Okoński
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
# PublicActivity [![Build Status](https://secure.travis-ci.org/chaps-io/public_activity.svg)](http://travis-ci.org/chaps-io/public_activity) [![Code Climate](https://codeclimate.com/github/chaps-io/public_activity.svg)](https://codeclimate.com/github/chaps-io/public_activity) [![Gem Version](https://badge.fury.io/rb/public_activity.svg)](http://badge.fury.io/rb/public_activity)
|
2
|
+
|
3
|
+
`public_activity` provides easy activity tracking for your **ActiveRecord**, **Mongoid 3** and **MongoMapper** models
|
4
|
+
in Rails 3.0 - 5.0. Simply put: it records what has been changed or created and gives you the ability to present those
|
5
|
+
recorded activities to users - in a similar way to how GitHub does it.
|
6
|
+
|
7
|
+
## Rails 6
|
8
|
+
|
9
|
+
**As of 1.6.4 version, public_activity also supports Rails up to 6.0.**
|
10
|
+
|
11
|
+
## Table of contents
|
12
|
+
|
13
|
+
- [PublicActivity ![Build Status](http://travis-ci.org/chaps-io/public_activity) ![Code Climate](https://codeclimate.com/github/chaps-io/public_activity) ![Gem Version](http://badge.fury.io/rb/public_activity)](#publicactivity-build-statushttptravis-ciorgchaps-iopublicactivity-code-climatehttpscodeclimatecomgithubchaps-iopublicactivity-gem-versionhttpbadgefuryiorbpublicactivity)
|
14
|
+
- [Rails 6](#rails-6)
|
15
|
+
- [Table of contents](#table-of-contents)
|
16
|
+
- [Example](#example)
|
17
|
+
- [Online demo](#online-demo)
|
18
|
+
- [Screencast](#screencast)
|
19
|
+
- [Setup](#setup)
|
20
|
+
- [Gem installation](#gem-installation)
|
21
|
+
- [Database setup](#database-setup)
|
22
|
+
- [Model configuration](#model-configuration)
|
23
|
+
- [Custom activities](#custom-activities)
|
24
|
+
- [Displaying activities](#displaying-activities)
|
25
|
+
- [Layouts](#layouts)
|
26
|
+
- [Locals](#locals)
|
27
|
+
- [Activity views](#activity-views)
|
28
|
+
- [i18n](#i18n)
|
29
|
+
- [Testing](#testing)
|
30
|
+
- [Documentation](#documentation)
|
31
|
+
- [Common examples](#common-examples)
|
32
|
+
- [Help](#help)
|
33
|
+
- [License](#license)
|
34
|
+
|
35
|
+
## Example
|
36
|
+
|
37
|
+
Here is a simple example showing what this gem is about:
|
38
|
+
|
39
|
+
![Example usage](http://i.imgur.com/q0TVx.png)
|
40
|
+
|
41
|
+
### Online demo
|
42
|
+
|
43
|
+
You can see an actual application using this gem here: http://public-activity-example.herokuapp.com/feed
|
44
|
+
|
45
|
+
The source code of the demo is hosted here: https://github.com/pokonski/activity_blog
|
46
|
+
|
47
|
+
## Screencast
|
48
|
+
|
49
|
+
Ryan Bates made a [great screencast](http://railscasts.com/episodes/406-public-activity) describing how to integrate Public Activity in your Rails Application.
|
50
|
+
|
51
|
+
## Setup
|
52
|
+
|
53
|
+
### Gem installation
|
54
|
+
|
55
|
+
You can install `public_activity` as you would any other gem:
|
56
|
+
|
57
|
+
gem install public_activity
|
58
|
+
|
59
|
+
or in your Gemfile:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
gem 'public_activity'
|
63
|
+
```
|
64
|
+
|
65
|
+
### Database setup
|
66
|
+
|
67
|
+
By default _public_activity_ uses Active Record. If you want to use Mongoid or MongoMapper as your backend, create
|
68
|
+
an initializer file in your Rails application with the corresponding code inside:
|
69
|
+
|
70
|
+
For _Mongoid:_
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
# config/initializers/public_activity.rb
|
74
|
+
PublicActivity::Config.set do
|
75
|
+
orm :mongoid
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
For _MongoMapper:_
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
# config/initializers/public_activity.rb
|
83
|
+
PublicActivity::Config.set do
|
84
|
+
orm :mongo_mapper
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
**(ActiveRecord only)** Create migration for activities and migrate the database (in your Rails project):
|
89
|
+
|
90
|
+
rails g public_activity:migration
|
91
|
+
rake db:migrate
|
92
|
+
|
93
|
+
### Model configuration
|
94
|
+
|
95
|
+
Include `PublicActivity::Model` and add `tracked` to the model you want to keep track of:
|
96
|
+
|
97
|
+
For _ActiveRecord:_
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
class Article < ActiveRecord::Base
|
101
|
+
include PublicActivity::Model
|
102
|
+
tracked
|
103
|
+
end
|
104
|
+
```
|
105
|
+
|
106
|
+
For _Mongoid:_
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
class Article
|
110
|
+
include Mongoid::Document
|
111
|
+
include PublicActivity::Model
|
112
|
+
tracked
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
116
|
+
For _MongoMapper:_
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
class Article
|
120
|
+
include MongoMapper::Document
|
121
|
+
include PublicActivity::Model
|
122
|
+
tracked
|
123
|
+
end
|
124
|
+
```
|
125
|
+
|
126
|
+
And now, by default create/update/destroy activities are recorded in activities table.
|
127
|
+
This is all you need to start recording activities for basic CRUD actions.
|
128
|
+
|
129
|
+
_Optional_: If you don't need `#tracked` but still want the comfort of `#create_activity`,
|
130
|
+
you can include only the lightweight `Common` module instead of `Model`.
|
131
|
+
|
132
|
+
#### Custom activities
|
133
|
+
|
134
|
+
You can trigger custom activities by setting all your required parameters and triggering `create_activity`
|
135
|
+
on the tracked model, like this:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
@article.create_activity key: 'article.commented_on', owner: current_user
|
139
|
+
```
|
140
|
+
|
141
|
+
See this entry http://rubydoc.info/gems/public_activity/PublicActivity/Common:create_activity for more details.
|
142
|
+
|
143
|
+
### Displaying activities
|
144
|
+
|
145
|
+
To display them you simply query the `PublicActivity::Activity` model:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
# notifications_controller.rb
|
149
|
+
def index
|
150
|
+
@activities = PublicActivity::Activity.all
|
151
|
+
end
|
152
|
+
```
|
153
|
+
|
154
|
+
And in your views:
|
155
|
+
|
156
|
+
```erb
|
157
|
+
<%= render_activities(@activities) %>
|
158
|
+
```
|
159
|
+
|
160
|
+
*Note*: `render_activity` is a helper for use in view templates. `render_activity(activity)` can be written as `activity.render(self)` and it will have the same meaning.
|
161
|
+
|
162
|
+
*Note*: `render_activities` is an alias for `render_activity` and does the same.
|
163
|
+
|
164
|
+
#### Layouts
|
165
|
+
|
166
|
+
You can also pass options to both `activity#render` and `#render_activity` methods, which are passed deeper
|
167
|
+
to the internally used `render_partial` method.
|
168
|
+
A useful example would be to render activities wrapped in layout, which shares common elements of an activity,
|
169
|
+
like a timestamp, owner's avatar etc:
|
170
|
+
|
171
|
+
```erb
|
172
|
+
<%= render_activities(@activities, layout: :activity) %>
|
173
|
+
```
|
174
|
+
|
175
|
+
The activity will be wrapped with the `app/views/layouts/_activity.erb` layout, in the above example.
|
176
|
+
|
177
|
+
**Important**: please note that layouts for activities are also partials. Hence the `_` prefix.
|
178
|
+
|
179
|
+
#### Locals
|
180
|
+
|
181
|
+
Sometimes, it's desirable to pass additional local variables to partials. It can be done this way:
|
182
|
+
|
183
|
+
```erb
|
184
|
+
<%= render_activity(@activity, locals: {friends: current_user.friends}) %>
|
185
|
+
```
|
186
|
+
|
187
|
+
*Note*: Before 1.4.0, one could pass variables directly to the options hash for `#render_activity` and access it from activity parameters. This functionality is retained in 1.4.0 and later, but the `:locals` method is **preferred**, since it prevents bugs from shadowing variables from activity parameters in the database.
|
188
|
+
|
189
|
+
#### Activity views
|
190
|
+
|
191
|
+
`public_activity` looks for views in `app/views/public_activity`.
|
192
|
+
|
193
|
+
For example, if you have an activity with `:key` set to `"activity.user.changed_avatar"`, the gem will look for a partial in `app/views/public_activity/user/_changed_avatar.(erb|haml|slim|something_else)`.
|
194
|
+
|
195
|
+
*Hint*: the `"activity."` prefix in `:key` is completely optional and kept for backwards compatibility, you can skip it in new projects.
|
196
|
+
|
197
|
+
If a view file does not exist, then p_a falls back to the old behaviour and tries to translate the activity `:key` using `I18n#translate` method (see the section below).
|
198
|
+
|
199
|
+
#### i18n
|
200
|
+
|
201
|
+
Translations are used by the `#text` method, to which you can pass additional options in form of a hash. `#render` method uses translations when view templates have not been provided. You can render pure i18n strings by passing `{display: :i18n}` to `#render_activity` or `#render`.
|
202
|
+
|
203
|
+
Translations should be put in your locale `.yml` files. To render pure strings from I18n Example structure:
|
204
|
+
|
205
|
+
```yaml
|
206
|
+
activity:
|
207
|
+
article:
|
208
|
+
create: 'Article has been created'
|
209
|
+
update: 'Someone has edited the article'
|
210
|
+
destroy: 'Some user removed an article!'
|
211
|
+
```
|
212
|
+
|
213
|
+
This structure is valid for activities with keys `"activity.article.create"` or `"article.create"`. As mentioned before, `"activity."` part of the key is optional.
|
214
|
+
|
215
|
+
## Testing
|
216
|
+
|
217
|
+
For RSpec you can first disable `public_activity` and add the `test_helper` in `rails_helper.rb` with:
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
#rails_helper.rb
|
221
|
+
require 'public_activity/testing'
|
222
|
+
|
223
|
+
PublicActivity.enabled = false
|
224
|
+
```
|
225
|
+
|
226
|
+
In your specs you can then blockwise decide wether to turn `public_activity` on
|
227
|
+
or off.
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
# file_spec.rb
|
231
|
+
PublicActivity.with_tracking do
|
232
|
+
# your test code goes here
|
233
|
+
end
|
234
|
+
|
235
|
+
PublicActivity.without_tracking do
|
236
|
+
# your test code goes here
|
237
|
+
end
|
238
|
+
```
|
239
|
+
|
240
|
+
## Documentation
|
241
|
+
|
242
|
+
For more documentation go [here](http://rubydoc.info/gems/public_activity/index)
|
243
|
+
|
244
|
+
## Common examples
|
245
|
+
|
246
|
+
* [[How to] Set the Activity's owner to current_user by default](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Set-the-Activity's-owner-to-current_user-by-default)
|
247
|
+
* [[How to] Disable tracking for a class or globally](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Disable-tracking-for-a-class-or-globally)
|
248
|
+
* [[How to] Create custom activities](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Create-custom-activities)
|
249
|
+
* [[How to] Use custom fields on Activity](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Use-custom-fields-on-Activity)
|
250
|
+
|
251
|
+
## Help
|
252
|
+
|
253
|
+
If you need help with using public_activity please visit our discussion group and ask a question there:
|
254
|
+
|
255
|
+
https://groups.google.com/forum/?fromgroups#!forum/public-activity
|
256
|
+
|
257
|
+
Please do not ask general questions in the Github Issues.
|
258
|
+
|
259
|
+
## License
|
260
|
+
Copyright (c) 2011-2013 Piotrek Okoński, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require 'rake'
|
5
|
+
require 'yard'
|
6
|
+
require 'yard/rake/yardoc_task'
|
7
|
+
require 'rake/testtask'
|
8
|
+
|
9
|
+
task :default => :test
|
10
|
+
|
11
|
+
desc 'Generate documentation for the public_activity plugin.'
|
12
|
+
YARD::Rake::YardocTask.new do |doc|
|
13
|
+
doc.files = ['lib/**/*.rb']
|
14
|
+
end
|
15
|
+
|
16
|
+
Rake::TestTask.new do |t|
|
17
|
+
t.libs << "test"
|
18
|
+
t.test_files = FileList['test/test*.rb']
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/named_base'
|
4
|
+
|
5
|
+
module PublicActivity
|
6
|
+
# A generator module with Activity table schema.
|
7
|
+
module Generators
|
8
|
+
# A base module
|
9
|
+
module Base
|
10
|
+
# Get path for migration template
|
11
|
+
def source_root
|
12
|
+
@_public_activity_source_root ||= File.expand_path(File.join('../public_activity', generator_name, 'templates'), __FILE__)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'generators/public_activity'
|
4
|
+
require 'rails/generators/active_record'
|
5
|
+
|
6
|
+
module PublicActivity
|
7
|
+
module Generators
|
8
|
+
# Migration generator that creates migration file from template
|
9
|
+
class MigrationGenerator < ActiveRecord::Generators::Base
|
10
|
+
extend Base
|
11
|
+
|
12
|
+
argument :name, :type => :string, :default => 'create_activities'
|
13
|
+
# Create migration in project's folder
|
14
|
+
def generate_files
|
15
|
+
migration_template 'migration.rb', "db/migrate/#{name}.rb"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'generators/public_activity'
|
4
|
+
require 'rails/generators/active_record'
|
5
|
+
|
6
|
+
module PublicActivity
|
7
|
+
module Generators
|
8
|
+
# Migration generator that creates migration file from template
|
9
|
+
class MigrationUpgradeGenerator < ActiveRecord::Generators::Base
|
10
|
+
extend Base
|
11
|
+
|
12
|
+
argument :name, :type => :string, :default => 'upgrade_activities'
|
13
|
+
# Create migration in project's folder
|
14
|
+
def generate_files
|
15
|
+
migration_template 'upgrade.rb', "db/migrate/#{name}.rb"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Migration responsible for creating a table with activities
|
4
|
+
class UpgradeActivities < ActiveRecord::Migration
|
5
|
+
# Create table
|
6
|
+
def self.change
|
7
|
+
change_table :activities do |t|
|
8
|
+
t.belongs_to :recipient, :polymorphic => true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
require 'action_view'
|
5
|
+
# +public_activity+ keeps track of changes made to models
|
6
|
+
# and allows you to display them to the users.
|
7
|
+
#
|
8
|
+
# Check {PublicActivity::Tracked::ClassMethods#tracked} for more details about customizing and specifying
|
9
|
+
# ownership to users.
|
10
|
+
module PublicActivity
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
extend ActiveSupport::Autoload
|
13
|
+
|
14
|
+
autoload :Activity, 'public_activity/models/activity'
|
15
|
+
autoload :Activist, 'public_activity/models/activist'
|
16
|
+
autoload :Adapter, 'public_activity/models/adapter'
|
17
|
+
autoload :Trackable, 'public_activity/models/trackable'
|
18
|
+
autoload :Common
|
19
|
+
autoload :Config
|
20
|
+
autoload :Creation, 'public_activity/actions/creation.rb'
|
21
|
+
autoload :Deactivatable,'public_activity/roles/deactivatable.rb'
|
22
|
+
autoload :Destruction, 'public_activity/actions/destruction.rb'
|
23
|
+
autoload :Renderable
|
24
|
+
autoload :Tracked, 'public_activity/roles/tracked.rb'
|
25
|
+
autoload :Update, 'public_activity/actions/update.rb'
|
26
|
+
autoload :VERSION
|
27
|
+
|
28
|
+
# Switches PublicActivity on or off.
|
29
|
+
# @param value [Boolean]
|
30
|
+
# @since 0.5.0
|
31
|
+
def self.enabled=(value)
|
32
|
+
config.enabled(value)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns `true` if PublicActivity is on, `false` otherwise.
|
36
|
+
# Enabled by default.
|
37
|
+
# @return [Boolean]
|
38
|
+
# @since 0.5.0
|
39
|
+
def self.enabled?
|
40
|
+
config.enabled
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns PublicActivity's configuration object.
|
44
|
+
# @since 0.5.0
|
45
|
+
def self.config
|
46
|
+
@@config ||= PublicActivity::Config.instance
|
47
|
+
end
|
48
|
+
|
49
|
+
# Method used to choose which ORM to load
|
50
|
+
# when PublicActivity::Activity class is being autoloaded
|
51
|
+
def self.inherit_orm(model="Activity")
|
52
|
+
orm = PublicActivity.config.orm
|
53
|
+
require "public_activity/orm/#{orm.to_s}"
|
54
|
+
"PublicActivity::ORM::#{orm.to_s.classify}::#{model}".constantize
|
55
|
+
end
|
56
|
+
|
57
|
+
# Module to be included in ActiveRecord models. Adds required functionality.
|
58
|
+
module Model
|
59
|
+
extend ActiveSupport::Concern
|
60
|
+
included do
|
61
|
+
include Common
|
62
|
+
include Deactivatable
|
63
|
+
include Tracked
|
64
|
+
include Activist # optional associations by recipient|owner
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
require 'public_activity/utility/store_controller'
|
70
|
+
require 'public_activity/utility/view_helpers'
|