Class: RailsPerformance::Models::ResourceRecord
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- RailsPerformance::Models::ResourceRecord
- Defined in:
- lib/rails_performance/models/resource_record.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#datetimei ⇒ Object
Returns the value of attribute datetimei.
-
#json ⇒ Object
Returns the value of attribute json.
-
#role ⇒ Object
Returns the value of attribute role.
-
#server ⇒ Object
Returns the value of attribute server.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(server:, context:, role:, datetime:, datetimei:, json:) ⇒ ResourceRecord
constructor
A new instance of ResourceRecord.
- #record_hash ⇒ Object
- #save ⇒ Object
Methods inherited from BaseRecord
Constructor Details
#initialize(server:, context:, role:, datetime:, datetimei:, json:) ⇒ ResourceRecord
Returns a new instance of ResourceRecord.
6 7 8 9 10 11 12 13 |
# File 'lib/rails_performance/models/resource_record.rb', line 6 def initialize(server:, context:, role:, datetime:, datetimei:, json:) @server = server @context = context @role = role @datetime = datetime @datetimei = datetimei @json = json end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
4 5 6 |
# File 'lib/rails_performance/models/resource_record.rb', line 4 def context @context end |
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/rails_performance/models/resource_record.rb', line 4 def datetime @datetime end |
#datetimei ⇒ Object
Returns the value of attribute datetimei.
4 5 6 |
# File 'lib/rails_performance/models/resource_record.rb', line 4 def datetimei @datetimei end |
#json ⇒ Object
Returns the value of attribute json.
4 5 6 |
# File 'lib/rails_performance/models/resource_record.rb', line 4 def json @json end |
#role ⇒ Object
Returns the value of attribute role.
4 5 6 |
# File 'lib/rails_performance/models/resource_record.rb', line 4 def role @role end |
#server ⇒ Object
Returns the value of attribute server.
4 5 6 |
# File 'lib/rails_performance/models/resource_record.rb', line 4 def server @server end |
Class Method Details
.from_db(key, value) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rails_performance/models/resource_record.rb', line 15 def self.from_db(key, value) items = key.split("|") ResourceRecord.new( server: items[2], context: items[4], role: items[6], datetime: items[8], datetimei: items[10], json: value ) end |
Instance Method Details
#record_hash ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rails_performance/models/resource_record.rb', line 28 def record_hash value.symbolize_keys.merge({ server: server, role: role, context: context, datetime: datetime, datetimei: RailsPerformance::Utils.from_datetimei(datetimei.to_i) }) end |
#save ⇒ Object
38 39 40 41 42 |
# File 'lib/rails_performance/models/resource_record.rb', line 38 def save key = "resource|server|#{server}|context|#{context}|role|#{role}|datetime|#{datetime}|datetimei|#{datetimei}|END|#{RailsPerformance::SCHEMA}" # with longer expiration time Utils.save_to_redis(key, json, RailsPerformance.system_monitor_duration.to_i) end |