Class: Flipper::Exporters::Json::Export

Inherits:
Flipper::Export show all
Defined in:
lib/flipper/exporters/json/export.rb

Overview

Internal: JSON export class that knows how to build features hash from data.

Instance Attribute Summary

Attributes inherited from Flipper::Export

#contents, #format, #version

Instance Method Summary collapse

Methods inherited from Flipper::Export

#adapter, #eql?

Constructor Details

#initialize(contents:, version: 1) ⇒ Export

Returns a new instance of Export.



14
15
16
# File 'lib/flipper/exporters/json/export.rb', line 14

def initialize(contents:, version: 1)
  super contents: contents, version: version, format: :json
end

Instance Method Details

#featuresObject

Public: The features hash identical to calling get_all on adapter.



19
20
21
22
23
24
25
26
27
28
# File 'lib/flipper/exporters/json/export.rb', line 19

def features
  @features ||= begin
    features = JSON.parse(contents).fetch("features")
    Typecast.features_hash(features)
  rescue JSON::ParserError
    raise JsonError
  rescue
    raise InvalidError
  end
end