Sha256: 377239fc91809ded4925f4ba151d9a3a770ba837f881e37bf1f41cc5c5b90c14
Contents?: true
Size: 972 Bytes
Versions: 6
Compression:
Stored size: 972 Bytes
Contents
module Flipper module Api module V1 module Decorators class Gate < SimpleDelegator # Public the gate being decorated alias_method :gate, :__getobj__ # Public: the value for the gate from the adapter. attr_reader :value def initialize(gate, value = nil) super gate @value = value end def as_json(exclude_name: false) as_json = { 'key' => gate.key.to_s, 'value' => value_as_json, } as_json['name'] = gate.name.to_s unless exclude_name as_json end private # Set of types that should be represented as Array in JSON. JSON_ARRAY_TYPES = Set[:set].freeze # json doesn't like sets def value_as_json JSON_ARRAY_TYPES.include?(data_type) ? value.to_a : value end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems