Class: RailsLiveDashboard::Types::JobContent
- Inherits:
-
ActiveRecord::Type::Value
- Object
- ActiveRecord::Type::Value
- RailsLiveDashboard::Types::JobContent
- Defined in:
- app/models/rails_live_dashboard/types/job_content.rb
Defined Under Namespace
Classes: CONTENT_STRUCT
Constant Summary collapse
- PAYLOAD =
%i[ job_name job_id params status queue_name started_at finished_at duration db_duration error history ].freeze
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
25 26 27 28 29 30 |
# File 'app/models/rails_live_dashboard/types/job_content.rb', line 25 def cast(value) return value if value.is_a?(CONTENT_STRUCT) sanitized = sanitize_input(value) CONTENT_STRUCT.new(**sanitized) end |
#deserialize(value) ⇒ Object
32 33 34 35 36 |
# File 'app/models/rails_live_dashboard/types/job_content.rb', line 32 def deserialize(value) decoded = ActiveSupport::JSON.decode(value)&.symbolize_keys sanitized = sanitize_input(decoded) CONTENT_STRUCT.new(**sanitized) end |
#serialize(value) ⇒ Object
38 39 40 |
# File 'app/models/rails_live_dashboard/types/job_content.rb', line 38 def serialize(value) ActiveSupport::JSON.encode(value) end |
#type ⇒ Object
21 22 23 |
# File 'app/models/rails_live_dashboard/types/job_content.rb', line 21 def type :jsonb end |