class ActivityNotification::ORM::Mongoid::Notification

Notification model implementation generated by ActivityNotification.

Public Class Methods

raise_delete_restriction_error(error_text) click to toggle source

Raise ActivityNotification::DeleteRestrictionError for notifications. @param [String] error_text Error text for raised exception @raise [ActivityNotification::DeleteRestrictionError] DeleteRestrictionError from used ORM @return [void]

# File lib/activity_notification/orm/mongoid/notification.rb, line 202
def self.raise_delete_restriction_error(error_text)
  raise ActivityNotification::DeleteRestrictionError, error_text
end

Public Instance Methods

group_owner?() click to toggle source

Returns if the notification is group owner. Calls NotificationApi#group_owner? as super method. @return [Boolean] If the notification is group owner

# File lib/activity_notification/orm/mongoid/notification.rb, line 194
def group_owner?
  super
end

Protected Instance Methods

opened_group_member_count(limit = ActivityNotification.config.opened_index_limit) click to toggle source

Returns count of group members of the opened notification. This method is designed to cache group by query result to avoid N+1 call. @api protected @todo Avoid N+1 call

@param [Integer] limit Limit to query for opened notifications @return [Integer] Count of group members of the opened notification

# File lib/activity_notification/orm/mongoid/notification.rb, line 225
def opened_group_member_count(limit = ActivityNotification.config.opened_index_limit)
  limit == 0 and return 0
  group_members.opened_only(limit).to_a.length #.count(true)
end
opened_group_member_notifier_count(limit = ActivityNotification.config.opened_index_limit) click to toggle source

Returns count of group member notifiers of the opened notification not including group owner notifier. This method is designed to cache group by query result to avoid N+1 call. @api protected @todo Avoid N+1 call

@param [Integer] limit Limit to query for opened notifications @return [Integer] Count of group member notifiers of the opened notification

# File lib/activity_notification/orm/mongoid/notification.rb, line 251
def opened_group_member_notifier_count(limit = ActivityNotification.config.opened_index_limit)
  limit == 0 and return 0
  group_members.opened_only(limit)
               .where(notifier_type: notifier_type)
               .where(:notifier_id.ne => notifier_id)
               .distinct(:notifier_id)
               .to_a.length #.count(true)
end
unopened_group_member_count() click to toggle source

Returns count of group members of the unopened notification. This method is designed to cache group by query result to avoid N+1 call. @api protected @todo Avoid N+1 call

@return [Integer] Count of group members of the unopened notification

# File lib/activity_notification/orm/mongoid/notification.rb, line 214
def unopened_group_member_count
  group_members.unopened_only.count
end
unopened_group_member_notifier_count() click to toggle source

Returns count of group member notifiers of the unopened notification not including group owner notifier. This method is designed to cache group by query result to avoid N+1 call. @api protected @todo Avoid N+1 call

@return [Integer] Count of group member notifiers of the unopened notification

# File lib/activity_notification/orm/mongoid/notification.rb, line 236
def unopened_group_member_notifier_count
  group_members.unopened_only
               .where(notifier_type: notifier_type)
               .where(:notifier_id.ne => notifier_id)
               .distinct(:notifier_id)
               .count
end