Class: ActivityNotification::ORM::Mongoid::Subscription
- Inherits:
-
Object
- Object
- ActivityNotification::ORM::Mongoid::Subscription
- Includes:
- Association, SubscriptionApi, Mongoid::Attributes::Dynamic, Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/activity_notification/orm/mongoid/subscription.rb
Overview
Subscription model implementation generated by ActivityNotification.
Class Method Summary collapse
-
.filtered_by_target ⇒ Mongoid::Criteria<Subscription>
Selects filtered subscriptions by target instance.
-
.uniq_keys ⇒ Array<String>
Selects unique keys from query for subscriptions.
Instance Method Summary collapse
-
#target ⇒ Object
Belongs to target instance of this subscription as polymorphic association.
-
#where ⇒ Mongoid::Criteria<Subscription>
Selects filtered subscriptions by type of the object.
-
#with_target ⇒ Mongoid::Criteria<Subscription>
Includes target instance with query for subscriptions.
Methods included from SubscriptionApi
#as_json, #optional_target_names, #subscribe, #subscribe_to_email, #subscribe_to_optional_target, #subscribing_to_optional_target?, #unsubscribe, #unsubscribe_to_email, #unsubscribe_to_optional_target
Methods included from Association
Methods included from Mongoid::Document
Class Method Details
.filtered_by_target ⇒ Mongoid::Criteria<Subscription>
Selects filtered subscriptions by target instance.
ActivityNotification::Subscription.filtered_by_target(@user)
is the same as
@user.subscriptions
53 |
# File 'lib/activity_notification/orm/mongoid/subscription.rb', line 53 scope :filtered_by_target, ->(target) { filtered_by_association("target", target) } |
.uniq_keys ⇒ Array<String>
Selects unique keys from query for subscriptions.
64 65 66 67 68 |
# File 'lib/activity_notification/orm/mongoid/subscription.rb', line 64 def self.uniq_keys # distinct method cannot keep original sort # distinct(:key) pluck(:key).uniq end |
Instance Method Details
#target ⇒ Object
Belongs to target instance of this subscription as polymorphic association.
19 |
# File 'lib/activity_notification/orm/mongoid/subscription.rb', line 19 belongs_to_polymorphic_xdb_record :target |
#where ⇒ Mongoid::Criteria<Subscription>
Selects filtered subscriptions by type of the object. Filtering with ActivityNotification::Subscription is defined as default scope.
44 |
# File 'lib/activity_notification/orm/mongoid/subscription.rb', line 44 default_scope -> { where(_type: "ActivityNotification::Subscription") } |
#with_target ⇒ Mongoid::Criteria<Subscription>
Includes target instance with query for subscriptions.
57 |
# File 'lib/activity_notification/orm/mongoid/subscription.rb', line 57 scope :with_target, -> { } |