Class: Rubory::Factory

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

Instance Method Summary collapse

Constructor Details

#initialize(name, context) ⇒ Factory

Returns a new instance of Factory.



86
87
88
89
90
91
# File 'lib/factories.rb', line 86

def initialize(name, context)
  @context = context
  @name = name
  @attributes = {}
  @counter = 0
end

Instance Method Details

#build(attribute_overrides) ⇒ Object



95
96
97
# File 'lib/factories.rb', line 95

def build(attribute_overrides)
  @context.create_instance class_name, Hash[ attributes(attribute_overrides) ]
end

#value_for(attribute, &block) ⇒ Object



92
93
94
# File 'lib/factories.rb', line 92

def value_for(attribute, &block)
  @attributes[attribute] = block;
end