Module: Likeable::ClassMethods
- Defined in:
- lib/likeable.rb
Overview
Class Methods ### —————– # allows us to setup callbacks when creating likes after_like :notify_users allows us to setup callbacks when destroying likes after_unlike :notify_users
Instance Method Summary collapse
- #after_like(*methods) ⇒ Object
- #after_unlike(*methods) ⇒ Object
- #all_liked_by(user) ⇒ Object
- #all_liked_ids_by(user) ⇒ Object
Instance Method Details
#after_like(*methods) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/likeable.rb', line 110 def after_like(*methods) define_method(:after_like) do |like| methods.each do |method| eval("#{method}(like)") end end end |
#after_unlike(*methods) ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/likeable.rb', line 118 def after_unlike(*methods) define_method(:after_unlike) do |user| methods.each do |method| eval("#{method}(user)") end end end |