Class: ActivityNotification::ORM::Dynamoid::Notification
- Inherits:
-
Object
- Object
- ActivityNotification::ORM::Dynamoid::Notification
- Includes:
- ActiveModel::AttributeAssignment, Association, Common, DynamoidExtension, NotificationApi, Renderable, Dynamoid::Document, GlobalID::Identification
- Defined in:
- lib/activity_notification/orm/dynamoid/notification.rb
Overview
Notification model implementation generated by ActivityNotification.
Class Method Summary collapse
-
.raise_delete_restriction_error(error_text) ⇒ void
Raise ActivityNotification::DeleteRestrictionError for notifications.
Instance Method Summary collapse
-
#after_store ⇒ Object
Call after store action with stored notification.
-
#group ⇒ Object
Belongs to group instance of this notification as polymorphic association using composite key.
-
#group_members ⇒ Dynamoid::Criteria::Chain
Has many group member notification instances of this notification.
-
#group_owner ⇒ Notification
Customized method that belongs to group owner notification instance of this notification.
-
#group_owner? ⇒ Boolean
Returns if the notification is group owner.
-
#notifiable ⇒ Object
Belongs to notifiable instance of this notification as polymorphic association using composite key.
-
#notifier ⇒ Object
Belongs to :otifier instance of this notification.
-
#prepare_to_store ⇒ Object
Returns prepared notification object to store.
-
#target ⇒ Object
Belongs to target instance of this notification as polymorphic association using composite key.
Methods included from NotificationApi
#email_subscribed?, #group_member?, #group_member_count, #group_member_exists?, #group_member_notifier_count, #group_member_notifier_exists?, #group_notification_count, #group_notifier_count, #latest_group_member, #notifiable_path, #open!, #opened?, #optional_target_names, #optional_target_subscribed?, #optional_targets, #printable_notifiable_name, #publish_to_optional_targets, #remove_from_group, #send_notification_email, #subscribed?, #unopened?
Methods included from Association
Methods included from Renderable
#layout_path, #partial_path, #prepare_assigns, #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
Methods included from DynamoidExtension
Class Method Details
.raise_delete_restriction_error(error_text) ⇒ void
This method returns an undefined value.
Raise ActivityNotification::DeleteRestrictionError for notifications.
161 162 163 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 161 def self.raise_delete_restriction_error(error_text) raise ActivityNotification::DeleteRestrictionError, error_text end |
Instance Method Details
#after_store ⇒ Object
Call after store action with stored notification
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 91 def after_store if group_owner? self.stored_group_notification_count = group_notification_count self.stored_group_member_notifier_count = group_member_notifier_count self.stored_group_members = group_members.as_json self.stored_group_members.each do |group_member| # Cast Time and DateTime field to String to handle Dynamoid unsupported type error group_member.each do |k, v| group_member[k] = v.to_s if v.is_a?(Time) || v.is_a?(DateTime) end end save else group_owner.after_store end end |
#group ⇒ Object
Belongs to group instance of this notification as polymorphic association using composite key.
33 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 33 belongs_to_composite_xdb_record :group, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_group_name] } |
#group_members ⇒ Dynamoid::Criteria::Chain
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. has_many :group_members, class_name: “ActivityNotification::Notification”, foreign_key: :group_owner_id
60 61 62 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 60 def group_members Notification.where(group_owner_id: id) end |
#group_owner ⇒ Notification
Customized method that belongs to group owner notification instance of this notification.
45 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 45 belongs_to :group_owner, { class_name: "ActivityNotification::Notification", foreign_key: :group_owner_id, optional: true } |
#group_owner? ⇒ Boolean
Returns if the notification is group owner. Calls NotificationApi#group_owner? as super method.
153 154 155 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 153 def group_owner? super end |
#notifiable ⇒ Object
Belongs to notifiable instance of this notification as polymorphic association using composite key.
28 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 28 belongs_to_composite_xdb_record :notifiable, store_with_associated_records: true, as_json_options: { methods: [:printable_type] } |
#notifier ⇒ Object
Belongs to :otifier instance of this notification.
67 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 67 belongs_to_composite_xdb_record :notifier, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_notifier_name] } |
#prepare_to_store ⇒ Object
Returns prepared notification object to store
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 79 def prepare_to_store self.stored_notifiable_path = notifiable_path self.stored_printable_notifiable_name = printable_notifiable_name if group_owner? self.stored_group_notification_count = 0 self.stored_group_member_notifier_count = 0 self.stored_group_members = [] end self end |
#target ⇒ Object
Belongs to target instance of this notification as polymorphic association using composite key.
23 |
# File 'lib/activity_notification/orm/dynamoid/notification.rb', line 23 belongs_to_composite_xdb_record :target, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_target_name] } |