Class: Rollgeist::Report
- Inherits:
-
Object
- Object
- Rollgeist::Report
- Defined in:
- lib/rollgeist/report.rb
Instance Attribute Summary collapse
-
#access_location ⇒ Object
readonly
Returns the value of attribute access_location.
-
#accessed_at ⇒ Object
readonly
Returns the value of attribute accessed_at.
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#changed_attributes ⇒ Object
readonly
Returns the value of attribute changed_attributes.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
-
#record_id ⇒ Object
readonly
Returns the value of attribute record_id.
-
#rollback_location ⇒ Object
readonly
Returns the value of attribute rollback_location.
-
#rolled_back_at ⇒ Object
readonly
Returns the value of attribute rolled_back_at.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#watchpoint ⇒ Object
readonly
Returns the value of attribute watchpoint.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(access_location:, accessed_at:, action:, changed_attributes:, model_name:, record_id:, rollback_location:, rolled_back_at:, values:, watchpoint:) ⇒ Report
constructor
A new instance of Report.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(access_location:, accessed_at:, action:, changed_attributes:, model_name:, record_id:, rollback_location:, rolled_back_at:, values:, watchpoint:) ⇒ Report
Returns a new instance of Report.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rollgeist/report.rb', line 43 def initialize( access_location:, accessed_at:, action:, changed_attributes:, model_name:, record_id:, rollback_location:, rolled_back_at:, values:, watchpoint: ) @access_location = access_location @accessed_at = accessed_at @action = action @changed_attributes = changed_attributes @model_name = model_name @record_id = record_id @rollback_location = rollback_location @rolled_back_at = rolled_back_at @values = values @watchpoint = watchpoint freeze end |
Instance Attribute Details
#access_location ⇒ Object (readonly)
Returns the value of attribute access_location.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def access_location @access_location end |
#accessed_at ⇒ Object (readonly)
Returns the value of attribute accessed_at.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def accessed_at @accessed_at end |
#action ⇒ Object (readonly)
Returns the value of attribute action.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def action @action end |
#changed_attributes ⇒ Object (readonly)
Returns the value of attribute changed_attributes.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def changed_attributes @changed_attributes end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def model_name @model_name end |
#record_id ⇒ Object (readonly)
Returns the value of attribute record_id.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def record_id @record_id end |
#rollback_location ⇒ Object (readonly)
Returns the value of attribute rollback_location.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def rollback_location @rollback_location end |
#rolled_back_at ⇒ Object (readonly)
Returns the value of attribute rolled_back_at.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def rolled_back_at @rolled_back_at end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def values @values end |
#watchpoint ⇒ Object (readonly)
Returns the value of attribute watchpoint.
5 6 7 |
# File 'lib/rollgeist/report.rb', line 5 def watchpoint @watchpoint end |
Class Method Details
.build(record:, mark:, watchpoint:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rollgeist/report.rb', line 16 def self.build(record:, mark:, watchpoint:) changed_attributes = mark.changed_attributes values = changed_attributes.to_h do |attribute| [attribute, safely_read(record, attribute)] end new( access_location: Rollgeist.capture_location, accessed_at: Time.now, action: mark.action, changed_attributes: changed_attributes, model_name: record.class.name || record.class.to_s, record_id: record.id, rollback_location: mark.rollback_location, rolled_back_at: mark.rolled_back_at, values: values, watchpoint: watchpoint ) end |
Instance Method Details
#to_h ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rollgeist/report.rb', line 68 def to_h { access_location: access_location, accessed_at: accessed_at, action: action, changed_attributes: changed_attributes, model_name: model_name, record_id: record_id, rollback_location: rollback_location, rolled_back_at: rolled_back_at, values: values, watchpoint: watchpoint } end |