Class: FactoryGirl::AttributeAssigner Private

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_girl/attribute_assigner.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

- (AttributeAssigner) initialize(evaluator, build_class, &instance_builder)

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 AttributeAssigner



4
5
6
7
8
9
10
# File 'lib/factory_girl/attribute_assigner.rb', line 4

def initialize(evaluator, build_class, &instance_builder)
  @build_class = build_class
  @instance_builder         = instance_builder
  @evaluator                = evaluator
  @attribute_list           = evaluator.class.attribute_list
  @attribute_names_assigned = []
end

Instance Method Details

- (Object) hash

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.



22
23
24
25
26
27
28
29
# File 'lib/factory_girl/attribute_assigner.rb', line 22

def hash
  @evaluator.instance = build_hash

  attributes_to_set_on_hash.inject({}) do |result, attribute|
    result[attribute] = get(attribute)
    result
  end
end

- (Object) 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.



12
13
14
15
16
17
18
19
20
# File 'lib/factory_girl/attribute_assigner.rb', line 12

def object
  @evaluator.instance = build_class_instance
  build_class_instance.tap do |instance|
    attributes_to_set_on_instance.each do |attribute|
      instance.public_send("#{attribute}=", get(attribute))
      @attribute_names_assigned << attribute
    end
  end
end