1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_girl/attribute_group.rb

30 lines
570 B
Ruby
Raw Normal View History

2011-08-09 20:29:02 -04:00
module FactoryGirl
class AttributeGroup
attr_reader :name
2011-08-12 14:38:33 -04:00
2011-08-09 20:29:02 -04:00
def initialize(name, &block) #:nodoc:
@name = name
2011-08-12 14:38:33 -04:00
@attribute_list = AttributeList.new
2011-08-09 20:29:02 -04:00
proxy = FactoryGirl::DefinitionProxy.new(self)
proxy.instance_eval(&block) if block_given?
end
def define_attribute(attribute)
2011-08-12 14:38:33 -04:00
@attribute_list.define_attribute(attribute)
2011-08-09 20:29:02 -04:00
end
2011-08-12 14:38:33 -04:00
2011-08-10 18:19:25 -04:00
def add_callback(name, &block)
2011-08-12 14:38:33 -04:00
@attribute_list.add_callback(name, &block)
2011-08-10 18:19:25 -04:00
end
2011-08-12 14:38:33 -04:00
def attributes
@attribute_list.to_a
end
2011-08-10 14:11:53 -04:00
def names
[@name]
end
2011-08-09 20:29:02 -04:00
end
end