Module: Predictable::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/predictable/user.rb
Overview
Predictable User Role
Defines the User role for the recommender. This module should be included in the User model of the appliation.
class User < ActiveRecord::Base
include Predictable::User
...
end
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_to_recommender(attrs = {}) ⇒ Object
Creates or updates a user in prediction.io When the user id already exists it updates the user.
-
#delete_from_recommender ⇒ Object
Removes the user from prediction.io.
-
#pio_uid ⇒ Object
Returns the user id.
-
#record_action(action, item, opts = {}) ⇒ Object
Record a user action in the recommender.
- #record_conversion(item, opts = {}) ⇒ Object
Instance Method Details
#add_to_recommender(attrs = {}) ⇒ Object
Creates or updates a user in prediction.io When the user id already exists it updates the user. The operation is done asynchronously.
41 42 43 44 |
# File 'lib/predictable/user.rb', line 41 def add_to_recommender(attrs={}) recommender.create_user(self, attrs) nil end |
#delete_from_recommender ⇒ Object
Removes the user from prediction.io. The operation is done asynchronously.
48 49 50 51 |
# File 'lib/predictable/user.rb', line 48 def delete_from_recommender recommender.delete_user(self) nil end |
#pio_uid ⇒ Object
Returns the user id
18 19 20 |
# File 'lib/predictable/user.rb', line 18 def pio_uid self.id end |
#record_action(action, item, opts = {}) ⇒ Object
Record a user action in the recommender. Actions cannot be overwritten or deleted in prediction.io The operation is done asynchronously.
user.record_action(:conversion, item)
28 29 30 31 |
# File 'lib/predictable/user.rb', line 28 def record_action(action, item, opts={}) recommender.record_action(self, action, item, opts) nil end |
#record_conversion(item, opts = {}) ⇒ Object
33 34 35 36 |
# File 'lib/predictable/user.rb', line 33 def record_conversion(item, opts={}) record_action(:conversion, item, opts) nil end |