Sha256: 5a2c4ed263678c034b8388f41f489959ab8de6efe65aebaa0729cfb79c685425
Contents?: true
Size: 851 Bytes
Versions: 2
Compression:
Stored size: 851 Bytes
Contents
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 declare_attribute(declaration) @attribute_list.declare_attribute(declaration) declaration end def add_callback(name, &block) @attribute_list.add_callback(Callback.new(name, block)) end def attributes AttributeList.new.tap do |list| @attribute_list.declarations.each do |declaration| declaration.to_attributes.each do |attribute| list.define_attribute(attribute) end end list.apply_attributes @attribute_list end end def names [@name] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
factory_girl-2.2.0 | lib/factory_girl/trait.rb |
factory_girl-2.1.2 | lib/factory_girl/trait.rb |