Module: CruFlags::Document
- Defined in:
- lib/cru_flags/document.rb
Constant Summary collapse
- EMPTY =
{"Flags" => {}.freeze}.freeze
Class Method Summary collapse
-
.parse(body) ⇒ Object
Parse and deep-freeze one flag document.
Class Method Details
.parse(body) ⇒ Object
Parse and deep-freeze one flag document. Leniency is for ABSENCE, not malformation: a missing Flags key is an empty document, a wrong-typed one is a broken document (design doc ยง8).
14 15 16 17 18 19 20 21 |
# File 'lib/cru_flags/document.rb', line 14 def parse(body) parsed = JSON.parse(body, freeze: true) raise ParseError, "document is not a JSON object" unless parsed.is_a?(Hash) normalize_flags(parsed) rescue JSON::ParserError => e raise ParseError, "document is not JSON: #{e.}" end |