def property(name, type, options = {})
caller_method = caller[2]
if TrueClass == type
warn "#{type} is deprecated, use Boolean instead at #{caller_method}"
type = DataMapper::Property::Boolean
elsif BigDecimal == type
warn "#{type} is deprecated, use Decimal instead at #{caller_method}"
type = DataMapper::Property::Decimal
end
klass = DataMapper::Property.determine_class(type)
unless klass
raise ArgumentError, "+type+ was #{type.inspect}, which is not a supported type"
end
property = klass.new(self, name, options, type < DataMapper::Type ? type : nil)
repository_name = self.repository_name
properties = properties(repository_name)
properties << property
if repository_name == default_repository_name
@properties.except(repository_name).each do |repository_name, properties|
next if properties.named?(name)
DataMapper.repository(repository_name) do
properties << klass.new(self, name, options, type)
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) << self
end
end
descendants.each do |descendant|
descendant.properties(repository_name)[name] ||= property
end
create_reader_for(property)
create_writer_for(property)
return property
end