Class: RailsPerformance::Models::CustomRecord
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- RailsPerformance::Models::CustomRecord
- Defined in:
- lib/rails_performance/models/custom_record.rb
Instance Attribute Summary collapse
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#datetimei ⇒ Object
Returns the value of attribute datetimei.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#json ⇒ Object
Returns the value of attribute json.
-
#namespace_name ⇒ Object
Returns the value of attribute namespace_name.
-
#status ⇒ Object
Returns the value of attribute status.
-
#tag_name ⇒ Object
Returns the value of attribute tag_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name:, namespace_name: nil, duration: nil, datetime:, datetimei:, status:, json: '{}') ⇒ CustomRecord
constructor
A new instance of CustomRecord.
- #record_hash ⇒ Object
- #save ⇒ Object
Methods inherited from BaseRecord
Constructor Details
#initialize(tag_name:, namespace_name: nil, duration: nil, datetime:, datetimei:, status:, json: '{}') ⇒ CustomRecord
Returns a new instance of CustomRecord.
19 20 21 22 23 24 25 26 27 |
# File 'lib/rails_performance/models/custom_record.rb', line 19 def initialize(tag_name:, namespace_name: nil, duration: nil, datetime:, datetimei:, status:, json: '{}') @tag_name = tag_name @namespace_name = namespace_name @duration = duration @datetime = datetime @datetimei = datetimei.to_i @status = status @json = json end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/rails_performance/models/custom_record.rb', line 4 def datetime @datetime end |
#datetimei ⇒ Object
Returns the value of attribute datetimei.
4 5 6 |
# File 'lib/rails_performance/models/custom_record.rb', line 4 def datetimei @datetimei end |
#duration ⇒ Object
Returns the value of attribute duration.
4 5 6 |
# File 'lib/rails_performance/models/custom_record.rb', line 4 def duration @duration end |
#json ⇒ Object
Returns the value of attribute json.
4 5 6 |
# File 'lib/rails_performance/models/custom_record.rb', line 4 def json @json end |
#namespace_name ⇒ Object
Returns the value of attribute namespace_name.
4 5 6 |
# File 'lib/rails_performance/models/custom_record.rb', line 4 def namespace_name @namespace_name end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/rails_performance/models/custom_record.rb', line 4 def status @status end |
#tag_name ⇒ Object
Returns the value of attribute tag_name.
4 5 6 |
# File 'lib/rails_performance/models/custom_record.rb', line 4 def tag_name @tag_name end |
Class Method Details
.from_db(key, value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rails_performance/models/custom_record.rb', line 6 def CustomRecord.from_db(key, value) items = key.split("|") CustomRecord.new( tag_name: items[2], namespace_name: items[4], datetime: items[6], datetimei: items[8], status: items[10], json: value ) end |
Instance Method Details
#record_hash ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rails_performance/models/custom_record.rb', line 29 def record_hash { tag_name: self.tag_name, namespace_name: self.namespace_name, status: self.status, datetimei: datetimei, datetime: Time.at(self.datetimei.to_i), duration: self.value['duration'], } end |
#save ⇒ Object
40 41 42 43 44 |
# File 'lib/rails_performance/models/custom_record.rb', line 40 def save key = "custom|tag_name|#{tag_name}|namespace_name|#{namespace_name}|datetime|#{datetime}|datetimei|#{datetimei}|status|#{status}|END|#{RailsPerformance::SCHEMA}" value = { duration: duration } Utils.save_to_redis(key, value) end |