Sha256: 831989fc4b64fe15589fdf1cac46f735529d7250e4e7c499e6024b439ed57e99

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

require 'set'
require 'flipper/typecast'

module Flipper
  class GateValues
    attr_reader :boolean
    attr_reader :actors
    attr_reader :groups
    attr_reader :expression
    attr_reader :percentage_of_actors
    attr_reader :percentage_of_time

    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])
      @expression = adapter_values[:expression]
      @percentage_of_actors = Typecast.to_number(adapter_values[:percentage_of_actors])
      @percentage_of_time = Typecast.to_number(adapter_values[:percentage_of_time])
    end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flipper-1.3.2 lib/flipper/gate_values.rb
flipper-1.3.1 lib/flipper/gate_values.rb
flipper-1.3.0 lib/flipper/gate_values.rb
flipper-1.3.0.pre lib/flipper/gate_values.rb
flipper-1.2.2 lib/flipper/gate_values.rb
flipper-1.2.1 lib/flipper/gate_values.rb
flipper-1.2.0 lib/flipper/gate_values.rb
flipper-1.1.2 lib/flipper/gate_values.rb
flipper-1.1.1 lib/flipper/gate_values.rb
flipper-1.1.0 lib/flipper/gate_values.rb