Class: ReeAudit::Event
- Inherits:
-
Object
- Object
- ReeAudit::Event
- Defined in:
- lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb
Overview
One audited action call. Built by the transport layer (the ree_roda plugin), enriched by the application through ReeAudit.annotate, and handed to a sink once the call is over.
Constant Summary collapse
- STATUSES =
[:ok, :denied, :not_found, :error].freeze
Instance Attribute Summary collapse
-
#accessor ⇒ Object
Returns the value of attribute accessor.
-
#action_name ⇒ Object
Returns the value of attribute action_name.
-
#annotations ⇒ Object
Returns the value of attribute annotations.
-
#duration_ms ⇒ Object
Returns the value of attribute duration_ms.
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#error_type ⇒ Object
Returns the value of attribute error_type.
-
#on_annotation ⇒ Object
Returns the value of attribute on_annotation.
-
#package_name ⇒ Object
Returns the value of attribute package_name.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#request_method ⇒ Object
Returns the value of attribute request_method.
-
#request_path ⇒ Object
Returns the value of attribute request_path.
-
#sections ⇒ Object
Returns the value of attribute sections.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
-
#status ⇒ Object
Returns the value of attribute status.
-
#summary ⇒ Object
Returns the value of attribute summary.
Class Method Summary collapse
-
.build(action_name:, package_name: nil, summary: nil, sections: [], request_method: nil, path: nil, request_path: nil, params: {}, accessor: nil, on_annotation: false) ⇒ Object
Keyword-only on purpose: callers live in another package and must not depend on the order of the fields here.
Instance Method Summary collapse
- #denied? ⇒ Boolean
-
#initialize ⇒ Event
constructor
A new instance of Event.
- #ok? ⇒ Boolean
-
#recordable? ⇒ Boolean
An
on_annotationevent is the same call seen from two sides: the client asking for its own data, and a staff member asking for the client's. - #to_h ⇒ Object
Constructor Details
#initialize ⇒ Event
Returns a new instance of Event.
47 48 49 50 51 52 53 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 47 def initialize @sections = [] @params = {} @annotations = {} @status = :ok @on_annotation = false end |
Instance Attribute Details
#accessor ⇒ Object
Returns the value of attribute accessor.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def accessor @accessor end |
#action_name ⇒ Object
Returns the value of attribute action_name.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def action_name @action_name end |
#annotations ⇒ Object
Returns the value of attribute annotations.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def annotations @annotations end |
#duration_ms ⇒ Object
Returns the value of attribute duration_ms.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def duration_ms @duration_ms end |
#error_message ⇒ Object
Returns the value of attribute error_message.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def @error_message end |
#error_type ⇒ Object
Returns the value of attribute error_type.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def error_type @error_type end |
#on_annotation ⇒ Object
Returns the value of attribute on_annotation.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def on_annotation @on_annotation end |
#package_name ⇒ Object
Returns the value of attribute package_name.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def package_name @package_name end |
#params ⇒ Object
Returns the value of attribute params.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def path @path end |
#request_method ⇒ Object
Returns the value of attribute request_method.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def request_method @request_method end |
#request_path ⇒ Object
Returns the value of attribute request_path.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def request_path @request_path end |
#sections ⇒ Object
Returns the value of attribute sections.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def sections @sections end |
#started_at ⇒ Object
Returns the value of attribute started_at.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def started_at @started_at end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def status @status end |
#summary ⇒ Object
Returns the value of attribute summary.
9 10 11 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 9 def summary @summary end |
Class Method Details
.build(action_name:, package_name: nil, summary: nil, sections: [], request_method: nil, path: nil, request_path: nil, params: {}, accessor: nil, on_annotation: false) ⇒ Object
Keyword-only on purpose: callers live in another package and must not depend on the order of the fields here.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 17 def build( action_name:, package_name: nil, summary: nil, sections: [], request_method: nil, path: nil, request_path: nil, params: {}, accessor: nil, on_annotation: false ) event = new event.action_name = action_name event.package_name = package_name event.summary = summary event.sections = sections || [] event.request_method = request_method event.path = path event.request_path = request_path event.params = params || {} event.accessor = accessor event.annotations = {} event.on_annotation = on_annotation event end |
Instance Method Details
#denied? ⇒ Boolean
59 60 61 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 59 def denied? status == :denied end |
#ok? ⇒ Boolean
55 56 57 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 55 def ok? status == :ok end |
#recordable? ⇒ Boolean
An on_annotation event is the same call seen from two sides: the client
asking for its own data, and a staff member asking for the client's. Only
the code that resolved the caller can tell them apart, and it says so by
annotating — so an untouched event of that kind is not worth recording.
67 68 69 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 67 def recordable? !on_annotation || !annotations.empty? end |
#to_h ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb', line 71 def to_h { action_name: action_name, package_name: package_name, summary: summary, sections: sections, request_method: request_method, path: path, request_path: request_path, params: params, status: status, error_type: error_type, error_message: , started_at: started_at, duration_ms: duration_ms, annotations: annotations } end |