Class: WellRested::CoreFormatter
- Inherits:
-
Object
- Object
- WellRested::CoreFormatter
- Defined in:
- lib/well_rested/core_formatter.rb
Instance Method Summary collapse
Instance Method Details
#decode(serialized_representation) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/well_rested/core_formatter.rb', line 8 def decode(serialized_representation) result = JSON.parse(serialized_representation) # 20120628 CR - Core returns the collection results in an array "items" => find_many() # If that doesn't exist, it is a single element, which can be returned as is => find() return result["items"] || result end |
#encode(obj) ⇒ Object
4 5 6 |
# File 'lib/well_rested/core_formatter.rb', line 4 def encode(obj) obj.to_json end |