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: {}) ⇒ Flag

Returns a new instance of Flag.



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

def initialize(flag_name, adapter:, context: nil, data: {})
  @flag_name = flag_name
  @adapter = adapter
  @context = context
  @data = data
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

Instance Method Details

#control?Boolean

Returns:

  • (Boolean)


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

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

#off?Boolean

Returns:

  • (Boolean)


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

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

#on?Boolean

Returns:

  • (Boolean)


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

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