Module: Predictable::Item
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/predictable/item.rb
Overview
Predictable Item Role
Defines the Item role for the recommender. This module should be included in any model that represents items that will be recommended.
class Offer < ActiveRecord::Base
include Predictable::Item
...
end
class Article < ActiveRecord::Base
include Predictable::Item
...
end
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_to_recommender(attrs = {}) ⇒ Object
Creates or updates the item in prediction.io When the item already exists, it updates it.
-
#delete_from_recommender ⇒ Object
Removes the item from prediction.io The operation is done asynchronously.
-
#pio_iid ⇒ Object
Returns the item id.
-
#pio_itypes ⇒ Object
Returns the item types.
Instance Method Details
#add_to_recommender(attrs = {}) ⇒ Object
Creates or updates the item in prediction.io When the item already exists, it updates it. The operation is done asynchronously.
37 38 39 40 |
# File 'lib/predictable/item.rb', line 37 def add_to_recommender(attrs={}) recommender.create_item(self, attrs) nil end |
#delete_from_recommender ⇒ Object
Removes the item from prediction.io The operation is done asynchronously.
44 45 46 47 |
# File 'lib/predictable/item.rb', line 44 def delete_from_recommender recommender.delete_item(self) nil end |
#pio_iid ⇒ Object
Returns the item id
25 26 27 |
# File 'lib/predictable/item.rb', line 25 def pio_iid "#{self.class.pio_itype}-#{id}" end |
#pio_itypes ⇒ Object
Returns the item types
30 31 32 |
# File 'lib/predictable/item.rb', line 30 def pio_itypes [self.class.pio_itype] end |