Module: MigratingSerializer::FlexibleLoader
- Defined in:
- lib/migrating_serializer/flexible_loader.rb
Overview
This module provides our flexible load method. It will check the data to see if it is YAML and then call YAML.load on it. If the data does not appear to be YAML then it will assume JSON and load it.
Class Method Summary collapse
Class Method Details
.load(data) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/migrating_serializer/flexible_loader.rb', line 11 def self.load(data) if data.start_with?('---') # we know its YAML YAML.load(data) else # we should be able to read as JSON JSON.load(data) end end |