Class: Dbwatcher::Storage::Session
- Inherits:
-
Object
- Object
- Dbwatcher::Storage::Session
- Defined in:
- lib/dbwatcher/storage/session.rb
Instance Attribute Summary collapse
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#ended_at ⇒ Object
Returns the value of attribute ended_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Session
constructor
A new instance of Session.
- #summary ⇒ Object
- #to_h ⇒ Object
-
#to_param ⇒ Object
Used by Rails URL helpers to convert the object to a URL parameter.
Constructor Details
#initialize(attrs = {}) ⇒ Session
Returns a new instance of Session.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dbwatcher/storage/session.rb', line 8 def initialize(attrs = {}) # Set default values @changes = [] @metadata = {} # Set provided attributes attrs.each do |key, value| setter_method = "#{key}=" send(setter_method, value) if respond_to?(setter_method) end end |
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
6 7 8 |
# File 'lib/dbwatcher/storage/session.rb', line 6 def changes @changes end |
#ended_at ⇒ Object
Returns the value of attribute ended_at.
6 7 8 |
# File 'lib/dbwatcher/storage/session.rb', line 6 def ended_at @ended_at end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/dbwatcher/storage/session.rb', line 6 def id @id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/dbwatcher/storage/session.rb', line 6 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/dbwatcher/storage/session.rb', line 6 def name @name end |
#started_at ⇒ Object
Returns the value of attribute started_at.
6 7 8 |
# File 'lib/dbwatcher/storage/session.rb', line 6 def started_at @started_at end |
Instance Method Details
#summary ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/dbwatcher/storage/session.rb', line 36 def summary return {} unless changes.is_a?(Array) valid_changes = filter_valid_changes group_changes_by_operation(valid_changes) rescue StandardError => e warn "Failed to calculate session summary: #{e.}" {} end |
#to_h ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dbwatcher/storage/session.rb', line 20 def to_h { id: id, name: name, metadata: , started_at: started_at, ended_at: ended_at, changes: changes } end |
#to_param ⇒ Object
Used by Rails URL helpers to convert the object to a URL parameter
32 33 34 |
# File 'lib/dbwatcher/storage/session.rb', line 32 def to_param id.to_s end |