Class: Tggl::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/tggl/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(flags, reporter = nil) ⇒ Response

Returns a new instance of Response.



5
6
7
8
# File 'lib/tggl/response.rb', line 5

def initialize(flags, reporter = nil)
  @flags = flags
  @reporter = reporter
end

Instance Method Details

#all_active_flagsObject



30
31
32
# File 'lib/tggl/response.rb', line 30

def all_active_flags
  @flags
end

#get(slug, default_value = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/tggl/response.rb', line 20

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

#is_active?(slug) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
# File 'lib/tggl/response.rb', line 10

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