module TroleGroups::Api::Event
Public Instance Methods
field_changed?(name)
click to toggle source
check if a field on the model changed See api.rubyonrails.org/classes/ActiveModel/Dirty.html
# File lib/trole_groups/api/event.rb, line 12 def field_changed? name send :"#{name}_changed?" end
publish_change(event)
click to toggle source
can be customized here uses singleton EventManager
# File lib/trole_groups/api/event.rb, line 18 def publish_change event send :invalidate_rolegroups_cache! if event == :role_groups event_manager.publish_change event, :from => self end
update_role_groups()
click to toggle source
a change to the roles of the user should be published to an event handler this can be used to update both the Role cache of the user and fx the RolePermit cache. Both (and potentially others, fx for Role Groups) can subscribe to this event!
# File lib/trole_groups/api/event.rb, line 6 def update_role_groups publish_change(:role_groups) if field_changed?(rolegroups_field) end
Protected Instance Methods
event_manager()
click to toggle source
# File lib/trole_groups/api/event.rb, line 25 def event_manager Troles::Common::EventManager end