module ActsAsShareable::Shareable::SingletonMethods

Add class methods here

Public Instance Methods

find_by_shared_to(object, *opts) click to toggle source

Find by shared to specified type

# File lib/acts_as_shareable/shareable.rb, line 41
def find_by_shared_to(object, *opts)
  joins("LEFT OUTER JOIN shares s ON s.shareable_id = #{self.table_name}.id")
  .where("s.shareable_type =? and s.shared_to_type=? and s.shared_to_id = ?", self, object.class.base_class, object.id)
end
find_by_shared_to_and_user(object, user, *opts) click to toggle source

Find shares by users and by specified type

# File lib/acts_as_shareable/shareable.rb, line 47
def find_by_shared_to_and_user(object, user, *opts)
  joins("LEFT OUTER JOIN shares s ON s.shareable_id = #{self.table_name}.id")
  .where("s.user_id = ? AND s.shareable_type =? and s.shared_to_type=? and s.shared_to_id = ?", user.id, self, object.class.base_class, object.id)
end
find_shares_by_user(user, *opts) click to toggle source

Find shares by users

# File lib/acts_as_shareable/shareable.rb, line 35
def find_shares_by_user(user, *opts)
  joins("LEFT OUTER JOIN shares s ON s.shareable_id = #{self.table_name}.id")
  .where("s.user_id = ? AND s.shareable_type =?", user.id, self)
end