Class: Featureflow::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/featureflow/feature.rb

Class Method Summary collapse

Class Method Details

.create(key, failover_variant = 'off') ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/featureflow/feature.rb', line 3

def self.create(key, failover_variant = 'off')
  raise ArgumentError, 'Parameter key must be a String' unless valid_key?(key)
  raise ArgumentError, 'Parameter failover_variant must be a String containing only letters, numbers, hyphens or underscores' unless valid_key?(failover_variant) || failover_variant.is_a?(NilClass)
  {
      key: key,
      failover_variant: failover_variant,
      variants: [{
                   key: 'on',
                   name: 'On'
                 },
                 {
                   key: 'off',
                   name: 'Off'
                 }]
  }
end