Class: FactoryBot::Decorator::AttributeHash

Inherits:
Decorator
  • Object
show all
Defined in:
lib/factory_bot/decorator/attribute_hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(component, attributes = []) ⇒ AttributeHash

Returns a new instance of AttributeHash.



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

def initialize(component, attributes = [])
  super(component)
  @attributes = attributes
end

Instance Method Details

#attributesObject



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

def attributes
  @attributes.each_with_object({}) do |attribute_name, result|
    result[attribute_name] = @component.send(attribute_name)
  end
end