Class: Spage::Serializers::Incident
- Inherits:
-
Object
- Object
- Spage::Serializers::Incident
- Defined in:
- lib/spage/serializers/incident.rb
Overview
Serializer for the Page resource
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(incident, update: false) ⇒ Incident
constructor
A new instance of Incident.
- #to_hash ⇒ Object
- #to_json(obj = nil) ⇒ Object
Constructor Details
#initialize(incident, update: false) ⇒ Incident
Returns a new instance of Incident.
8 9 10 11 |
# File 'lib/spage/serializers/incident.rb', line 8 def initialize(incident, update: false) @incident = incident @ivars = ivars(update) end |
Instance Method Details
#as_json ⇒ Object
17 18 19 |
# File 'lib/spage/serializers/incident.rb', line 17 def as_json to_hash end |
#to_hash ⇒ Object
21 22 23 24 25 26 27 28 29 |
# 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) ⇒ Object
13 14 15 |
# File 'lib/spage/serializers/incident.rb', line 13 def to_json(obj = nil) as_json.to_json(obj) end |