Class: ActivityNotification::ORM::ActiveRecord::Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActivityNotification::ORM::ActiveRecord::Notification
- Includes:
- Common, NotificationApi, Renderable
- Defined in:
- lib/activity_notification/orm/active_record/notification.rb
Overview
Notification model implementation generated by ActivityNotification.
Class Method Summary collapse
-
.earliest ⇒ Notification
Returns earliest notification instance.
-
.filtered_by_group ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects filtered notifications by group instance.
-
.filtered_by_instance ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects filtered notifications by notifiable instance.
-
.filtered_by_target ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects filtered notifications by target instance.
-
.group_members_of_owner_ids_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications with specified group owner ids.
-
.group_members_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications only.
-
.group_owners_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group owner notifications only.
-
.latest ⇒ Notification
Returns latest notification instance.
-
.opened_index_group_members_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications in opened_index.
-
.opened_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects opened notifications only with limit.
-
.opened_only! ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects opened notifications only without limit.
-
.raise_delete_restriction_error(error_text) ⇒ Object
Raise DeleteRestrictionError for notifications.
-
.uniq_keys ⇒ Array<String>
Selects unique keys from query for notifications.
-
.unopened_index_group_members_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications in unopened_index.
-
.unopened_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects unopened notifications only.
-
.within_expiration_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects notifications within expiration.
Instance Method Summary collapse
-
#group ⇒ Object
Belongs to group instance of this notification as polymorphic association.
-
#group_members ⇒ ActiveRecord_AssociationRelation<Notificaion>
Has many group member notification instances of this notification.
-
#group_owner ⇒ Notification
Belongs to group owner notification instance of this notification.
-
#notifiable ⇒ Object
Belongs to notifiable instance of this notification as polymorphic association.
-
#notifier ⇒ Object
Belongs to :notifier instance of this notification.
-
#target ⇒ Object
Belongs to target instance of this notification as polymorphic association.
-
#with_group ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes group instance with query for notifications.
-
#with_group_members ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes group member instances with query for notifications.
-
#with_group_owner ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes group owner instances with query for notifications.
-
#with_notifiable ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes notifiable instance with query for notifications.
-
#with_notifier ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes notifier instance with query for notifications.
-
#with_target ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes target instance with query for notifications.
Methods included from NotificationApi
all_index!, available_options, #earliest_order, #email_subscribed?, filtered_by_key, filtered_by_options, filtered_by_target_type, filtered_by_type, generate_notification, #group_member?, #group_member_count, group_member_exists?, #group_member_exists?, #group_member_notifier_count, #group_member_notifier_exists?, #group_notification_count, #group_notifier_count, #group_owner?, #latest_group_member, #latest_order, #notifiable_path, notify, notify_all, notify_to, #open!, open_all_of, #opened?, opened_index, #optional_target_names, #optional_target_subscribed?, #optional_targets, #publish_to_optional_targets, #remove_from_group, send_batch_notification_email, #send_notification_email, set_notification_mailer, #subscribed?, #unopened?, unopened_index
Methods included from Renderable
#layout_path, #partial_path, #prepare_locals, #prepare_parameters, #render, #text
Methods included from Common
#printable_name, #printable_type, #resolve_value, #to_class_name, #to_resource_name, #to_resources_name
Class Method Details
.earliest ⇒ Notification
Returns earliest notification instance.
163 164 165 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 163 def self.earliest earliest_order.first end |
.filtered_by_group ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects filtered notifications by group instance.
129 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 129 scope :filtered_by_group, ->(group) { where(group: group) } |
.filtered_by_instance ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects filtered notifications by notifiable instance.
121 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 121 scope :filtered_by_instance, ->(notifiable) { where(notifiable: notifiable) } |
.filtered_by_target ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects filtered notifications by target instance.
ActivityNotification::Notification.filtered_by_target(@user)
is the same as
@user.notifications
113 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 113 scope :filtered_by_target, ->(target) { where(target: target) } |
.group_members_of_owner_ids_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications with specified group owner ids.
104 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 104 scope :group_members_of_owner_ids_only, ->(owner_ids) { where(group_owner_id: owner_ids) } |
.group_members_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications only.
64 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 64 scope :group_members_only, -> { where.not(group_owner_id: nil) } |
.group_owners_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group owner notifications only.
59 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 59 scope :group_owners_only, -> { where(group_owner_id: nil) } |
.latest ⇒ Notification
Returns latest notification instance.
157 158 159 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 157 def self.latest latest_order.first end |
.opened_index_group_members_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications in opened_index.
92 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 92 scope :opened_index_group_members_only, ->(limit) { where(group_owner_id: opened_index(limit).map(&:id)) } |
.opened_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects opened notifications only with limit.
81 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 81 scope :opened_only, ->(limit) { opened_only!.limit(limit) } |
.opened_only! ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects opened notifications only without limit. Be careful to get too many records with this method.
75 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 75 scope :opened_only!, -> { where.not(opened_at: nil) } |
.raise_delete_restriction_error(error_text) ⇒ Object
Raise DeleteRestrictionError for notifications.
176 177 178 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 176 def self.raise_delete_restriction_error(error_text) raise ::ActiveRecord::DeleteRestrictionError.new(error_text) end |
.uniq_keys ⇒ Array<String>
Selects unique keys from query for notifications.
169 170 171 172 173 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 169 def self.uniq_keys # select method cannot be chained with order by other columns like created_at # select(:key).distinct.pluck(:key) pluck(:key).uniq end |
.unopened_index_group_members_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects group member notifications in unopened_index.
86 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 86 scope :unopened_index_group_members_only, -> { where(group_owner_id: unopened_index.map(&:id)) } |
.unopened_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects unopened notifications only.
69 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 69 scope :unopened_only, -> { where(opened_at: nil) } |
.within_expiration_only ⇒ ActiveRecord_AssociationRelation<Notificaion>
Selects notifications within expiration.
98 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 98 scope :within_expiration_only, ->(expiry_delay) { where("created_at > ?", expiry_delay.ago) } |
Instance Method Details
#group ⇒ Object
Belongs to group instance of this notification as polymorphic association.
28 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 28 belongs_to :group, { polymorphic: true }.merge(Rails::VERSION::MAJOR >= 5 ? { optional: true } : {}) |
#group_members ⇒ ActiveRecord_AssociationRelation<Notificaion>
Has many group member notification instances of this notification. Only group owner instance has :group_members value. Group member instance has nil as :group_members association.
42 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 42 has_many :group_members, class_name: "ActivityNotification::Notification", foreign_key: :group_owner_id |
#group_owner ⇒ Notification
Belongs to group owner notification instance of this notification. Only group member instance has :group_owner value. Group owner instance has nil as :group_owner association.
35 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 35 belongs_to :group_owner, { class_name: "ActivityNotification::Notification" }.merge(Rails::VERSION::MAJOR >= 5 ? { optional: true } : {}) |
#notifiable ⇒ Object
Belongs to notifiable instance of this notification as polymorphic association.
23 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 23 belongs_to :notifiable, polymorphic: true |
#notifier ⇒ Object
Belongs to :notifier instance of this notification.
47 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 47 belongs_to :notifier, { polymorphic: true }.merge(Rails::VERSION::MAJOR >= 5 ? { optional: true } : {}) |
#target ⇒ Object
Belongs to target instance of this notification as polymorphic association.
18 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 18 belongs_to :target, polymorphic: true |
#with_group ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes group instance with query for notifications.
141 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 141 scope :with_group, -> { includes(:group) } |
#with_group_members ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes group member instances with query for notifications.
149 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 149 scope :with_group_members, -> { includes(:group_members) } |
#with_group_owner ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes group owner instances with query for notifications.
145 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 145 scope :with_group_owner, -> { includes(:group_owner) } |
#with_notifiable ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes notifiable instance with query for notifications.
137 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 137 scope :with_notifiable, -> { includes(:notifiable) } |
#with_notifier ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes notifier instance with query for notifications.
153 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 153 scope :with_notifier, -> { includes(:notifier) } |
#with_target ⇒ ActiveRecord_AssociationRelation<Notificaion>
Includes target instance with query for notifications.
133 |
# File 'lib/activity_notification/orm/active_record/notification.rb', line 133 scope :with_target, -> { includes(:target) } |