Sha256: 0c6c0fdc928b0778131886d102e27eaef50ac92fedb2b7ea953699d450687ad5

Contents?: true

Size: 717 Bytes

Versions: 15

Compression:

Stored size: 717 Bytes

Contents

module Activities
  class ActivityObserver < ActiveRecord::Observer
    observe :activity

    def after_create(activity)
      self.class.send(:notify_subscribers, activity)
    end

    private
    class << self
      def notify_subscribers(activity)
        find_subscribers(activity).each do |subscriber|
          ActivityNotifier.deliver_new_content_notification(activity, subscriber) if activity.site.email_notification
        end
      end

      def find_subscribers(activity)
        [].tap do |subscribers|
          subscribers << User.by_role_and_context(:admin, activity.site)
          subscribers << User.by_role_and_context(:superuser, activity.site)
        end.flatten
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
adva-0.3.2 app/observers/activities/activity_observer.rb
adva-0.3.1 app/observers/activities/activity_observer.rb
adva-0.3.0 app/observers/activities/activity_observer.rb
adva-0.2.4 app/observers/activities/activity_observer.rb
adva-0.2.3 app/observers/activities/activity_observer.rb
adva-0.2.2 app/observers/activities/activity_observer.rb
adva-0.2.1 app/observers/activities/activity_observer.rb
adva-0.2.0 app/observers/activities/activity_observer.rb
adva-0.1.4 app/observers/activities/activity_observer.rb
adva-0.1.3 app/observers/activities/activity_observer.rb
adva-0.1.2 app/observers/activities/activity_observer.rb
adva-0.1.1 app/observers/activities/activity_observer.rb
adva-0.1.0 app/observers/activities/activity_observer.rb
adva_activity-0.0.1 app/observers/activities/activity_observer.rb
adva-0.0.1 adva_activity/app/observers/activities/activity_observer.rb