Class: Flipflop::FeatureDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/flipflop/feature_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, **options) ⇒ FeatureDefinition

Returns a new instance of FeatureDefinition.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/flipflop/feature_definition.rb', line 5

def initialize(key, **options)
  @key = key
  @name = @key.to_s.freeze
  @title = options.delete(:title).freeze || @name.humanize.freeze
  @description = options.delete(:description).freeze
  @default = !!options.delete(:default) || false
  @group = options.delete(:group).freeze
  @location = caller_locations(3, 1).first.freeze

  if options.any?
    raise FeatureError.new(name, "has unknown option #{options.keys.map(&:inspect) * ', '}")
  end
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



3
4
5
# File 'lib/flipflop/feature_definition.rb', line 3

def default
  @default
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/flipflop/feature_definition.rb', line 3

def description
  @description
end

#groupObject (readonly)

Returns the value of attribute group.



3
4
5
# File 'lib/flipflop/feature_definition.rb', line 3

def group
  @group
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/flipflop/feature_definition.rb', line 3

def key
  @key
end

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/flipflop/feature_definition.rb', line 3

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/flipflop/feature_definition.rb', line 3

def name
  @name
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/flipflop/feature_definition.rb', line 3

def title
  @title
end