def property(name, type, options = {})
if TrueClass == type
raise "#{type} is deprecated, use Boolean instead at #{caller[2]}"
elsif BigDecimal == type
raise "#{type} is deprecated, use Decimal instead at #{caller[2]}"
end
unless klass = DataMapper::Property.determine_class(type)
raise ArgumentError, "+type+ was #{type.inspect}, which is not a supported type"
end
property = klass.new(self, name, options)
repository_name = self.repository_name
properties = properties(repository_name)
properties << property
if repository_name == default_repository_name
other_repository_properties = DataMapper::Ext::Hash.except(@properties, default_repository_name)
other_repository_properties.each do |other_repository_name, properties|
next if properties.named?(name)
DataMapper.repository(other_repository_name) do
properties << klass.new(self, name, options)
end
end
end
if property.lazy?
context = options.fetch(:lazy, :default)
context = :default if context == true
Array(context).each do |context|
properties.lazy_context(context) << property
end
end
descendants.each do |descendant|
descendant.properties(repository_name) << property
end
create_reader_for(property)
create_writer_for(property)
return property
end