lib/flipper/gate_values.rb in flipper-0.8.0 vs lib/flipper/gate_values.rb in flipper-0.9.0.beta1

- old
+ new

@@ -2,17 +2,17 @@ module Flipper class GateValues # Private: Array of instance variables that are readable through the [] # instance method. - LegitIvars = Set.new([ - "boolean", - "actors", - "groups", - "percentage_of_time", - "percentage_of_actors", - ]).freeze + LegitIvars = { + "boolean" => "@boolean", + "actors" => "@actors", + "groups" => "@groups", + "percentage_of_time" => "@percentage_of_time", + "percentage_of_actors" => "@percentage_of_actors", + }.freeze attr_reader :boolean attr_reader :actors attr_reader :groups attr_reader :percentage_of_actors @@ -25,11 +25,12 @@ @percentage_of_actors = Typecast.to_integer(adapter_values[:percentage_of_actors]) @percentage_of_time = Typecast.to_integer(adapter_values[:percentage_of_time]) end def [](key) - return nil unless LegitIvars.include?(key.to_s) - instance_variable_get("@#{key}") + if ivar = LegitIvars[key.to_s] + instance_variable_get(ivar) + end end def eql?(other) self.class.eql?(other.class) && boolean == other.boolean &&