Sha256: f2eebded87c99fecafa51965b2b8508e6e77caa69edc0a53fd4d47acb7017502
Contents?: true
Size: 702 Bytes
Versions: 9
Compression:
Stored size: 702 Bytes
Contents
require_relative "../../../../lib/isimud" class Company < ActiveRecord::Base include Isimud::EventObserver has_many :users def self.find_active_observers where(active: true).all end def enable_listener? active end def observed_exchange 'isimud.test.events' end def routing_keys ["*.User.create", "*.User.destroy"] end def handle_event(event) user = User.find(event.parameters[:id]) return unless user.company_id == id raise "unexpected action: #{event.action}" unless ['create','destroy' ].include?(event.action.to_s) self.user_count = User.where(company: self).count self.total_points = user_count * points_per_user save! end end
Version data entries
9 entries across 9 versions & 1 rubygems