Class: Flipper::GateValues

Inherits:
Object
  • Object
show all
Defined in:
lib/flipper/gate_values.rb

Constant Summary collapse

LegitIvars =

Private: Array of instance variables that are readable through the [] instance method.

{
  "boolean" => "@boolean",
  "actors" => "@actors",
  "groups" => "@groups",
  "percentage_of_time" => "@percentage_of_time",
  "percentage_of_actors" => "@percentage_of_actors",
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter_values) ⇒ GateValues

Returns a new instance of GateValues.



21
22
23
24
25
26
27
# File 'lib/flipper/gate_values.rb', line 21

def initialize(adapter_values)
  @boolean = Typecast.to_boolean(adapter_values[:boolean])
  @actors = Typecast.to_set(adapter_values[:actors])
  @groups = Typecast.to_set(adapter_values[:groups])
  @percentage_of_actors = Typecast.to_integer(adapter_values[:percentage_of_actors])
  @percentage_of_time = Typecast.to_integer(adapter_values[:percentage_of_time])
end

Instance Attribute Details

#actorsObject (readonly)

Returns the value of attribute actors.



16
17
18
# File 'lib/flipper/gate_values.rb', line 16

def actors
  @actors
end

#booleanObject (readonly)

Returns the value of attribute boolean.



15
16
17
# File 'lib/flipper/gate_values.rb', line 15

def boolean
  @boolean
end

#groupsObject (readonly)

Returns the value of attribute groups.



17
18
19
# File 'lib/flipper/gate_values.rb', line 17

def groups
  @groups
end

#percentage_of_actorsObject (readonly)

Returns the value of attribute percentage_of_actors.



18
19
20
# File 'lib/flipper/gate_values.rb', line 18

def percentage_of_actors
  @percentage_of_actors
end

#percentage_of_timeObject (readonly)

Returns the value of attribute percentage_of_time.



19
20
21
# File 'lib/flipper/gate_values.rb', line 19

def percentage_of_time
  @percentage_of_time
end

Instance Method Details

#[](key) ⇒ Object



29
30
31
32
33
# File 'lib/flipper/gate_values.rb', line 29

def [](key)
  if ivar = LegitIvars[key.to_s]
    instance_variable_get(ivar)
  end
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
# File 'lib/flipper/gate_values.rb', line 35

def eql?(other)
  self.class.eql?(other.class) &&
    boolean == other.boolean &&
    actors == other.actors &&
    groups == other.groups &&
    percentage_of_actors == other.percentage_of_actors &&
    percentage_of_time == other.percentage_of_time
end