Class: Feeder::FeedableObserver
- Inherits:
-
ActiveRecord::Observer
- Object
- ActiveRecord::Observer
- Feeder::FeedableObserver
- Defined in:
- app/models/feeder/feedable_observer.rb
Instance Method Summary collapse
Instance Method Details
#after_create(feedable) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/feeder/feedable_observer.rb', line 5 def after_create(feedable) = feedable if condition = [:if] if condition.respond_to? :call return unless condition.call feedable else return unless feedable.send condition end end feedable.create_feeder_item! do |item| item.feedable = feedable item.created_at = feedable.created_at item.published_at = Time.zone.now if feedable.respond_to? :sticky item.sticky = feedable.sticky end end end |
#after_save(feedable) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/feeder/feedable_observer.rb', line 27 def after_save(feedable) item = feedable.feeder_item if item if feedable.respond_to? :sticky item.sticky = feedable.sticky end item.save! end end |