Class: ThisFeature::Flag

Inherits:
Object
  • Object
show all
Defined in:
lib/this_feature/flag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flag_name, adapter:, context: nil, data: {}, record: nil) ⇒ Flag

Returns a new instance of Flag.



5
6
7
8
9
10
11
# File 'lib/this_feature/flag.rb', line 5

def initialize(flag_name, adapter:, context: nil, data: {}, record: nil)
  @flag_name = flag_name
  @adapter = adapter
  @context = context
  @data = data
  @record = record
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



3
4
5
# File 'lib/this_feature/flag.rb', line 3

def adapter
  @adapter
end

#contextObject (readonly)

Returns the value of attribute context.



3
4
5
# File 'lib/this_feature/flag.rb', line 3

def context
  @context
end

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/this_feature/flag.rb', line 3

def data
  @data
end

#flag_nameObject (readonly)

Returns the value of attribute flag_name.



3
4
5
# File 'lib/this_feature/flag.rb', line 3

def flag_name
  @flag_name
end

#recordObject (readonly)

Returns the value of attribute record.



3
4
5
# File 'lib/this_feature/flag.rb', line 3

def record
  @record
end

Instance Method Details

#control?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/this_feature/flag.rb', line 21

def control?
  adapter.control?(flag_name, context: context, data: data, record: record)
end

#off?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/this_feature/flag.rb', line 17

def off?
  adapter.off?(flag_name, context: context, data: data, record: record)
end

#on?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/this_feature/flag.rb', line 13

def on?
  adapter.on?(flag_name, context: context, data: data, record: record)
end

#treatment_configObject



29
30
31
# File 'lib/this_feature/flag.rb', line 29

def treatment_config
  adapter.treatment_config(flag_name, context: context, data: data, record: record)
end

#treatment_valueObject



25
26
27
# File 'lib/this_feature/flag.rb', line 25

def treatment_value
  adapter.treatment_value(flag_name, context: context, data: data, record: record)
end