Method: Captive::Base::ClassMethods#from_json
- Defined in:
- lib/captive/base.rb
#from_json(json:, mapping: {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/captive/base.rb', line 18 def from_json(json:, mapping: {}) json = JSON.parse(json) if json.is_a?(String) cues = json['cues'] || json[:cues] raise InvalidJsonInput unless cues.is_a?(Array) cues.map! { |cue_json| Cue.from_json(json: cue_json, mapping: mapping) } new(cue_list: cues) end |