Class: ActivityNotification::ORM::ActiveRecord::Subscription
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActivityNotification::ORM::ActiveRecord::Subscription
- Includes:
- SubscriptionApi
- Defined in:
- lib/activity_notification/orm/active_record/subscription.rb
Overview
Subscription model implementation generated by ActivityNotification.
Class Method Summary collapse
-
.filtered_by_target ⇒ ActiveRecord_AssociationRelation<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.
-
#with_target ⇒ ActiveRecord_AssociationRelation<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
Class Method Details
.filtered_by_target ⇒ ActiveRecord_AssociationRelation<Subscription>
Selects filtered subscriptions by target instance.
ActivityNotification::Subscription.filtered_by_target(@user)
is the same as
@user.subscriptions
43 |
# File 'lib/activity_notification/orm/active_record/subscription.rb', line 43 scope :filtered_by_target, ->(target) { where(target: target) } |
.uniq_keys ⇒ Array<String>
Selects unique keys from query for subscriptions.
51 52 53 54 55 |
# File 'lib/activity_notification/orm/active_record/subscription.rb', line 51 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 |
Instance Method Details
#target ⇒ Object
Belongs to target instance of this subscription as polymorphic association.
14 |
# File 'lib/activity_notification/orm/active_record/subscription.rb', line 14 belongs_to :target, polymorphic: true |
#with_target ⇒ ActiveRecord_AssociationRelation<Subscription>
Includes target instance with query for subscriptions.
47 |
# File 'lib/activity_notification/orm/active_record/subscription.rb', line 47 scope :with_target, -> { includes(:target) } |