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

Commit

Permalink
Browse files Browse the repository at this point in the history
Add caller information to all deprecation warnings
[#979 state:resolved]
  • Loading branch information
dkubb committed Aug 19, 2009
1 parent 5dc4838 commit 88612ef
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/dm-core/core_ext/symbol.rb
Expand Up @@ -2,7 +2,7 @@ class Symbol
(DataMapper::Query::Conditions::Comparison.slugs | [ :not, :asc, :desc ]).each do |sym|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{sym}
#{"warn \"explicit use of '#{sym}' operator is deprecated\"" if sym == :eql || sym == :in}
#{"warn \"explicit use of '#{sym}' operator is deprecated (#{caller[0]})\"" if sym == :eql || sym == :in}
DataMapper::Query::Operator.new(self, #{sym.inspect})
end
RUBY
Expand Down
4 changes: 2 additions & 2 deletions lib/dm-core/model.rb
Expand Up @@ -28,7 +28,7 @@ def self.name
RUBY

if storage_name
warn "Passing in +storage_name+ to #{name}.new is deprecated"
warn "Passing in +storage_name+ to #{name}.new is deprecated (#{caller[0]})"
model.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def self.default_storage_name
#{Extlib::Inflection.classify(storage_name).inspect}.freeze
Expand Down Expand Up @@ -649,7 +649,7 @@ def _create(safe, attributes)
# @api private
def const_missing(name)
if name == :DM
warn "#{name} prefix deprecated and no longer necessary"
warn "#{name} prefix deprecated and no longer necessary (#{caller[0]})"
self
elsif name == :Resource
Resource
Expand Down
6 changes: 3 additions & 3 deletions lib/dm-core/property.rb
Expand Up @@ -796,14 +796,14 @@ def initialize(model, name, type, options = {})
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"
warn "#{type} with explicit :serial option is deprecated, use Serial instead (#{caller[2]})"
type = Types::Serial
elsif options.key?(:size)
if String == type
warn ":size option is deprecated, use #{type} with :length instead"
warn ":size option is deprecated, use #{type} with :length instead (#{caller[2]})"
options[:length] = options.delete(:size)
elsif Numeric > type
warn ':size option is deprecated, specify :min and :max instead'
warn ":size option is deprecated, specify :min and :max instead (#{caller[2]})"
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/dm-core/query/path.rb
Expand Up @@ -29,10 +29,10 @@ class Path

(Conditions::Comparison.slugs | [ :not ]).each do |slug|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{slug} # def eql
#{"warn \"explicit use of '#{slug}' operator is deprecated\"" if slug == :eql || slug == :in} # warn "explicit use of 'eql' operator is deprecated"
Operator.new(self, #{slug.inspect}) # Operator.new(self, :eql)
end # end
def #{slug} # def eql
#{"warn \"explicit use of '#{slug}' operator is deprecated (#{caller[0]})\"" if slug == :eql || slug == :in} # warn "explicit use of 'eql' operator is deprecated (#{caller[0]})"
Operator.new(self, #{slug.inspect}) # Operator.new(self, :eql)
end # end
RUBY
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dm-core/resource.rb
Expand Up @@ -36,7 +36,7 @@ def update_attributes(attributes = {}, *allowed)

if allowed.any?
warn "specifying allowed in #{model}#update_attributes is deprecated, " \
'use Hash#only to filter the attributes in the caller'
"use Hash#only to filter the attributes in the caller (#{caller[0]})"
attributes = attributes.only(*allowed)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dm-core/transaction.rb
Expand Up @@ -19,7 +19,7 @@ def initialize(*things)
@adapters = {}
link(*things)
if block_given?
warn "Passing block to #{self.class.name}.new is deprecated"
warn "Passing block to #{self.class.name}.new is deprecated (#{caller[0]})"
commit { |*block_args| yield(*block_args) }
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/dm-core/type.rb
Expand Up @@ -100,7 +100,7 @@ class << self
# TODO: document
# @api private
def configure(primitive_type, options)
warn 'DataMapper.Type.configure is deprecated, specify the primitive and options explicitly'
warn "DataMapper.Type.configure is deprecated, specify the primitive and options explicitly (#{caller[0]})"

@_primitive_type = primitive_type
@_options = options
Expand Down Expand Up @@ -191,7 +191,7 @@ def self.bind(property)

# @deprecated
def self.Type(primitive_type, options = {})
warn "DataMapper.Type(#{primitive_type}) is deprecated, specify the primitive and options explicitly"
warn "DataMapper.Type(#{primitive_type}) is deprecated, specify the primitive and options explicitly (#{caller[0]})"
Class.new(Type).configure(primitive_type, options)
end

Expand Down

0 comments on commit 88612ef

Please sign in to comment.