Module: Mongoid::Followit::Followee
- Defined in:
- lib/mongoid_followit/followee.rb
Overview
Class Method Summary collapse
Instance Method Summary collapse
-
#followers(criteria: false) ⇒ Object
Public: Peform a query to return all Mongoid model followers.
Class Method Details
Instance Method Details
#followers(criteria: false) ⇒ Object
Public: Peform a query to return all Mongoid model followers.
criteria(optional) - if true the return will be the type of
Mongoid::Criteria
Examples
class Person
include Mongoid::Document
include Mongoid::Followee
field :name, type: String
validates_uniqueness_of :name
end
# => Person.find_by(name: 'Skywalker').followers
Returns An Array of followers if criteria argument is false. Returns A Mongoid::Criteria of followers if criteria argument is true
and followers are of only one type
Raises HasTwoFollowerTypesError if criteria argument is true
and model has two or more types of followers
44 45 46 |
# File 'lib/mongoid_followit/followee.rb', line 44 def followers(criteria: false) follow_collection_for_a(:follower, criteria: criteria) end |