Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Improve deprecation messages I encountered during upgrading to 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Jun 9, 2009
1 parent 5426065 commit 491bd1e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/dm-core/model/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def belongs_to(name, options = {})
assert_kind_of 'options', options, Hash

if options.key?(:through)
warn "#{self.name}#belongs_to with :through is deprecated, use 'has 1, :#{name}, #{options.inspect}' in #{self.name} instead"
warn "#{self.name}#belongs_to with :through is deprecated, use 'has 1, :#{name}, #{options.inspect}' in #{self.name} instead (#{caller[0]})"
return has(1, name, options)
end

Expand Down Expand Up @@ -222,7 +222,7 @@ def assert_valid_options(options)

if options.key?(:class_name)
assert_kind_of 'options[:class_name]', options[:class_name], String
warn '+options[:class_name]+ is deprecated, use :model instead'
warn "+options[:class_name]+ is deprecated, use :model instead (#{caller[1]})"
options[:model] = options.delete(:class_name)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/dm-core/property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class Property
# @api semipublic
def field(repository_name = nil)
if repository_name
warn "Passing in +repository_name+ to #{self.class}#field is deprecated: #{caller[0]}"
warn "Passing in +repository_name+ to #{self.class}#field is deprecated (#{caller[0]})"

if repository_name != self.repository_name
raise ArgumentError, "Mismatching +repository_name+ with #{self.class}#repository_name (#{repository_name.inspect} != #{self.repository_name.inspect})"
Expand Down Expand Up @@ -783,7 +783,7 @@ def initialize(model, name, type, options = {})
options = options.dup

if TrueClass == type
warn "#{type} is deprecated, use Boolean instead"
warn "#{type} is deprecated, use Boolean instead at #{caller[2]}"
type = Types::Boolean
elsif Integer == type && options.delete(:serial)
warn "#{type} with explicit :serial option is deprecated, use Serial instead"
Expand Down
2 changes: 1 addition & 1 deletion lib/dm-core/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.extra_inclusions

# @deprecated
def self.descendants
warn 'DataMapper::Resource.descendants is deprecated, use DataMapper::Model.descendants instead'
warn "DataMapper::Resource.descendants is deprecated, use DataMapper::Model.descendants instead (#{caller[0]})"
DataMapper::Model.descendants
end

Expand Down

0 comments on commit 491bd1e

Please sign in to comment.