mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
29 lines
561 B
Ruby
29 lines
561 B
Ruby
module FactoryGirl
|
|
class Trait
|
|
attr_reader :name
|
|
|
|
def initialize(name, &block) #:nodoc:
|
|
@name = name
|
|
@attribute_list = AttributeList.new
|
|
|
|
proxy = FactoryGirl::DefinitionProxy.new(self)
|
|
proxy.instance_eval(&block) if block_given?
|
|
end
|
|
|
|
def define_attribute(attribute)
|
|
@attribute_list.define_attribute(attribute)
|
|
end
|
|
|
|
def add_callback(name, &block)
|
|
@attribute_list.add_callback(name, &block)
|
|
end
|
|
|
|
def attributes
|
|
@attribute_list.to_a
|
|
end
|
|
|
|
def names
|
|
[@name]
|
|
end
|
|
end
|
|
end
|