Class: FactoryBotFactory::Attribute
- Inherits:
-
Object
- Object
- FactoryBotFactory::Attribute
- Defined in:
- lib/factory_bot_factory/attribute.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(key, value, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(key, value, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
5 6 7 8 9 |
# File 'lib/factory_bot_factory/attribute.rb', line 5 def initialize(key, value, = {}) @key = key @value = value @options = end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/factory_bot_factory/attribute.rb', line 3 def key @key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/factory_bot_factory/attribute.rb', line 3 def @options end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/factory_bot_factory/attribute.rb', line 3 def value @value end |
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/factory_bot_factory/attribute.rb', line 11 def build = [key, value, ] values = if value.nil? || value == "null" FactoryBotFactory.config.nil_converter.call(*) elsif value.is_a?(String) || value.is_a?(Symbol) FactoryBotFactory.config.string_converter.call(*) elsif value.is_a?(Numeric) FactoryBotFactory.config.numertic_converter.call(*) elsif value.is_a?(Hash) || value.is_a?(Array) FactoryBotFactory.config.hash_converter.call(*) else value.is_a?(OpenStruct) FactoryBotFactory.config.open_struct_converter.call(*) end end |