Module: Hipaapotamus::Protected
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/hipaapotamus/protected.rb
Instance Method Summary collapse
- #authorize_access! ⇒ Object
- #authorize_creation! ⇒ Object
- #authorize_destruction! ⇒ Object
- #authorize_modification! ⇒ Object
- #hipaapotamus_display_name ⇒ Object
Instance Method Details
#authorize_access! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hipaapotamus/protected.rb', line 41 def accountability_context = AccountabilityContext.current! begin policy_class!.(accountability_context.agent, self, :access) accountability_context.record_action(self, :access) rescue AccountabilityError => error accountability_context.record_action(self, :attempted_access) raise error end end |
#authorize_creation! ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hipaapotamus/protected.rb', line 55 def accountability_context = AccountabilityContext.current! begin policy_class!.(accountability_context.agent, self, :creation) accountability_context.record_action(self, :creation, true) rescue AccountabilityError => error accountability_context.record_action(self, :attempted_creation) raise error end end |
#authorize_destruction! ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/hipaapotamus/protected.rb', line 83 def accountability_context = AccountabilityContext.current! begin policy_class!.(accountability_context.agent, self, :destruction) accountability_context.record_action(self, :destruction, true) rescue AccountabilityError => error accountability_context.record_action(self, :attempted_destruction) raise error end end |
#authorize_modification! ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/hipaapotamus/protected.rb', line 69 def accountability_context = AccountabilityContext.current! begin policy_class!.(accountability_context.agent, self, :modification) accountability_context.record_action(self, :modification, true) rescue AccountabilityError => error accountability_context.record_action(self, :attempted_modification) raise error end end |
#hipaapotamus_display_name ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/hipaapotamus/protected.rb', line 32 def hipaapotamus_display_name if new_record? "a new #{self.class.name}" else "#{self.class.name}(#{self.class.primary_key}=#{self[self.class.primary_key]})" end end |