Module: ActsAsSubscribable::SubscribableMethods::InstanceMethods
- Defined in:
- lib/acts_as_subscribable/subscribable_methods/instance_methods.rb
Instance Method Summary collapse
- #subscribe(subscriber) ⇒ Object
- #subscribed?(subscriber) ⇒ Boolean
- #subscribers ⇒ Object
- #unsubscribe(subscriber) ⇒ Object
Instance Method Details
#subscribe(subscriber) ⇒ Object
8 9 10 |
# File 'lib/acts_as_subscribable/subscribable_methods/instance_methods.rb', line 8 def subscribe(subscriber) send([:subscriber].tableize).send(:<<, subscriber) unless subscribed?(subscriber) end |
#subscribed?(subscriber) ⇒ Boolean
16 17 18 |
# File 'lib/acts_as_subscribable/subscribable_methods/instance_methods.rb', line 16 def subscribed?(subscriber) !subscriptions.where(:"#{[:subscriber_id]}" => subscriber.id).empty? end |
#subscribers ⇒ Object
4 5 6 |
# File 'lib/acts_as_subscribable/subscribable_methods/instance_methods.rb', line 4 def subscribers send [:subscriber].tableize end |
#unsubscribe(subscriber) ⇒ Object
12 13 14 |
# File 'lib/acts_as_subscribable/subscribable_methods/instance_methods.rb', line 12 def unsubscribe(subscriber) subscriber.subscriptions.where(:"#{[:subscribed_id]}" => id).delete_all end |