Sha256: cd423128d0b58a4344341bc973262d571351d43c6781f778330af3254e4ea6d5

Contents?: true

Size: 788 Bytes

Versions: 15

Compression:

Stored size: 788 Bytes

Contents

require 'json'

module Determinator
  module Serializers
    module JSON
      class << self
        def dump(feature)
          raise NotImplementedError
        end

        def load(string_or_hash)
          obj = string_or_hash.is_a?(Hash) ? string_or_hash : ::JSON.parse(string_or_hash)

          Determinator::Feature.new(
            name:            obj['name'],
            identifier:      obj['identifier'],
            bucket_type:     obj['bucket_type'],
            active:          (obj['active'] === true),
            target_groups:   obj['target_groups'],
            variants:        obj['variants'].to_h,
            overrides:       obj['overrides'].to_h,
            winning_variant: obj['winning_variant'].to_s,
          )
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
determinator-2.4.4 lib/determinator/serializers/json.rb
determinator-2.4.3 lib/determinator/serializers/json.rb
determinator-2.4.2 lib/determinator/serializers/json.rb
determinator-2.4.0 lib/determinator/serializers/json.rb
determinator-2.3.1 lib/determinator/serializers/json.rb
determinator-2.3.0 lib/determinator/serializers/json.rb
determinator-2.2.1 lib/determinator/serializers/json.rb
determinator-2.2.0 lib/determinator/serializers/json.rb
determinator-2.1.0 lib/determinator/serializers/json.rb
determinator-2.0.0 lib/determinator/serializers/json.rb
determinator-1.2.0 lib/determinator/serializers/json.rb
determinator-1.1.2 lib/determinator/serializers/json.rb
determinator-1.1.1 lib/determinator/serializers/json.rb
determinator-1.1.0 lib/determinator/serializers/json.rb
determinator-1.0.0 lib/determinator/serializers/json.rb