class Spage::Serializers::Incident
Serializer for the Page
resource
Public Class Methods
new(incident, update: false)
click to toggle source
# File lib/spage/serializers/incident.rb, line 8 def initialize(incident, update: false) @incident = incident @ivars = ivars(update) end
Public Instance Methods
as_json()
click to toggle source
# File lib/spage/serializers/incident.rb, line 17 def as_json to_hash end
to_hash()
click to toggle source
# File lib/spage/serializers/incident.rb, line 21 def to_hash { 'incident' => Hash[ @ivars.map do |name| [name[1..-1], @incident.instance_variable_get(name)] end ] } end
to_json(obj = nil)
click to toggle source
# File lib/spage/serializers/incident.rb, line 13 def to_json(obj = nil) as_json.to_json(obj) end
Private Instance Methods
ivars(update)
click to toggle source
# File lib/spage/serializers/incident.rb, line 33 def ivars(update) if update @incident.instance_variables.select do |name| processed_name = name[1..-1] update_attrs.include?(processed_name) && !@incident.send(processed_name).nil? end else @incident.instance_variables end end
update_attrs()
click to toggle source
rubocop: disable Metrics/MethodLength
# File lib/spage/serializers/incident.rb, line 46 def update_attrs %w[ name status impact_override scheduled_for scheduled_until scheduled_remind_prior scheduled_auto_in_progress scheduled_auto_completed metadata deliver_notifications auto_transition_deliver_notifications_at_end auto_transition_deliver_notifications_at_start auto_transition_to_maintenance_state auto_transition_to_operational_state auto_tweet_at_beginning auto_tweet_on_completion auto_tweet_on_creation auto_tweet_one_hour_before backfill_date backfilled body components component_ids scheduled_auto_transition ] end