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",
  "actors",
  "groups",
  "percentage_of_time",
  "percentage_of_actors",
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter_values) ⇒ GateValues

Returns a new instance of GateValues.



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

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.



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

def actors
  @actors
end

#booleanObject (readonly)

Returns the value of attribute boolean.



13
14
15
# File 'lib/flipper/gate_values.rb', line 13

def boolean
  @boolean
end

#groupsObject (readonly)

Returns the value of attribute groups.



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

def groups
  @groups
end

#percentage_of_actorsObject (readonly)

Returns the value of attribute percentage_of_actors.



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

def percentage_of_actors
  @percentage_of_actors
end

#percentage_of_timeObject (readonly)

Returns the value of attribute percentage_of_time.



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

def percentage_of_time
  @percentage_of_time
end

Instance Method Details

#[](key) ⇒ Object



27
28
29
30
# File 'lib/flipper/gate_values.rb', line 27

def [](key)
  return nil unless LegitIvars.include?(key.to_s)
  instance_variable_get("@#{key}")
end

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

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
# File 'lib/flipper/gate_values.rb', line 32

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