Sha256: 0ccc0118b2ffb883f3431bafa8e1738493a59d7ebeb5e0781a821b3c7f218acb
Contents?: true
Size: 770 Bytes
Versions: 19
Compression:
Stored size: 770 Bytes
Contents
class Factory class AttributeDefinitionError < RuntimeError end class Attribute #:nodoc: attr_reader :name def initialize (name, static_value, lazy_block) name = name.to_sym if name.to_s =~ /=$/ raise AttributeDefinitionError, "factory_girl uses 'f.#{name.to_s.chop} value' syntax " + "rather than 'f.#{name} = value'" end unless static_value.nil? || lazy_block.nil? raise AttributeDefinitionError, "Both value and block given" end @name = name @static_value = static_value @lazy_block = lazy_block end def value (proxy) if @lazy_block.nil? @static_value else @lazy_block.call(proxy) end end end end
Version data entries
19 entries across 19 versions & 8 rubygems