Class: LcpRuby::Permissions::ChangeHandler
- Inherits:
-
Object
- Object
- LcpRuby::Permissions::ChangeHandler
- Defined in:
- lib/lcp_ruby/permissions/change_handler.rb
Class Method Summary collapse
Class Method Details
.install!(model_class) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/lcp_ruby/permissions/change_handler.rb', line 4 def self.install!(model_class) fields = LcpRuby.configuration..transform_keys(&:to_s) target_model_field = fields["target_model"] model_class.after_commit do |record| model_name_value = record.public_send(target_model_field) if model_name_value.present? Registry.reload!(model_name_value) else Registry.reload! end # Policies capture perm_def in closures - must clear on any DB change Authorization::PolicyFactory.clear! end end |