Module: PyrRules::EventConcerns

Defined in:
app/rules/pyr_rules/event_concerns.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._register(klazz) ⇒ Object



10
11
12
13
# File 'app/rules/pyr_rules/event_concerns.rb', line 10

def self._register(klazz)
	self.registered_classes ||= []
	self.registered_classes << klazz if !self.registered_classes.index(klazz)
end

.included(base) ⇒ Object



6
7
8
# File 'app/rules/pyr_rules/event_concerns.rb', line 6

def self.included(base)
	_register(base)
end

Instance Method Details

#build_event_payload(event_type, class_name, action, extras = {}) ⇒ Object



15
16
17
18
19
20
# File 'app/rules/pyr_rules/event_concerns.rb', line 15

def build_event_payload(event_type, class_name, action, extras={})
		payload = { type: event_type, klazz: self.class.name, action: action, id: self.id, data: self, 
					user: Thread.current[:user] }.merge(extras)
		ActiveSupport::Notifications.instrument("PyrRules_#{event_type}", payload )

end