Sha256: fd58cfd3624930230b1037147dfd76d839c58b23f16e7925da87c7342ab0b301

Contents?: true

Size: 678 Bytes

Versions: 4

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

module Tggl
  class Response
    def initialize(flags, reporter = nil)
      @flags = flags
      @reporter = reporter
    end

    def is_active?(slug)
      active = @flags.key?(slug.to_sym)

      if @reporter != nil
        @reporter.report_flag(slug, active, active ? @flags[slug.to_sym] : nil)
      end

      active
    end

    def get(slug, default_value = nil)
      value = @flags.key?(slug.to_sym) ? @flags[slug.to_sym] : default_value

      if @reporter != nil
        @reporter.report_flag(slug, @flags.key?(slug.to_sym), value, default_value)
      end

      value
    end

    def all_active_flags
      @flags
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tggl-1.0.1 lib/tggl/response.rb
tggl-1.0.0 lib/tggl/response.rb
tggl-0.2.0 lib/tggl/response.rb
tggl-0.1.0 lib/tggl/response.rb