Module: Subscribable::RelationAssigner
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/subscribable/relation_assigner.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #delete_subscription_to!(actor) ⇒ Object
- #subscribe_to!(actor) ⇒ Object
- #subscribed_to?(actor) ⇒ Boolean
- #subscribers_from(*args) ⇒ Object
- #subscriptions_to(*args) ⇒ Object
Instance Method Details
#delete_subscription_to!(actor) ⇒ Object
33 34 35 36 |
# File 'lib/subscribable/relation_assigner.rb', line 33 def delete_subscription_to!(actor) subscription = subscription_with(actor) subscription.delete end |
#subscribe_to!(actor) ⇒ Object
27 28 29 30 31 |
# File 'lib/subscribable/relation_assigner.rb', line 27 def subscribe_to!(actor) sub = subscriptions.new sub.subscription = actor sub.save end |
#subscribed_to?(actor) ⇒ Boolean
38 39 40 41 |
# File 'lib/subscribable/relation_assigner.rb', line 38 def subscribed_to?(actor) query = actor.subscribers.where(subscriber_id: id, subscriber_type: self.class.name) query.empty? ? false : true end |
#subscribers_from(*args) ⇒ Object
19 20 21 |
# File 'lib/subscribable/relation_assigner.rb', line 19 def subscribers_from(*args) subscribers.where(subscriber_type: args) end |
#subscriptions_to(*args) ⇒ Object
23 24 25 |
# File 'lib/subscribable/relation_assigner.rb', line 23 def subscriptions_to(*args) subscriptions.where(subscription_type: args) end |