Class: FactoryBot::Enum Private

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_bot/enum.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(attribute_name, values = nil) ⇒ Enum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Enum.



4
5
6
7
# File 'lib/factory_bot/enum.rb', line 4

def initialize(attribute_name, values = nil)
  @attribute_name = attribute_name
  @values = values
end

Instance Method Details

#build_traits(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
12
13
# File 'lib/factory_bot/enum.rb', line 9

def build_traits(klass)
  enum_values(klass).map do |trait_name, value|
    build_trait(trait_name, @attribute_name, value || trait_name)
  end
end