Sha256: 1359251ebe68d5d9a90ba76760e05b8c5a31f4d0a84727e63a313e41448ecc47
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
module Flipper module Gates class Boolean < Gate TruthMap = { true => true, false => false, 'true' => true, 'false' => false, } # Internal: The name of the gate. Used for instrumentation, etc. def name :boolean end # Internal: Name converted to value safe for adapter. def key :boolean end def data_type :boolean end def description(value) if enabled?(value) 'Enabled' else 'Disabled' end end def enabled?(value) !!TruthMap[value] end # Internal: Checks if the gate is open for a thing. # # Returns true if explicitly set to true, false if explicitly set to false # or nil if not explicitly set. def open?(thing, value) instrument(:open?, thing) { |payload| !!TruthMap[value] } end def protects?(thing) thing.is_a?(Flipper::Types::Boolean) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems