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
Cleaned up deprecation warnings for :nullable
* When :nullable => true is required, change it to :required => false
  instead of :allow_nil => true.

[#1136 state:resolved]
  • Loading branch information
dkubb committed Dec 2, 2009
1 parent e1a3841 commit 5f9a0b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/dm-core/associations/many_to_one.rb
Expand Up @@ -148,8 +148,10 @@ def set(source, target)
# @api semipublic
def initialize(name, source_model, target_model, options = {})
if options.key?(:nullable)
warn ":nullable option is deprecated, use :required instead (#{caller[2]})"
options[:required] = !options.delete(:nullable)
nullable_options = options.only(:nullable)
required_options = { :required => !options.delete(:nullable) }
warn "#{nullable_options.inspect} is deprecated, use #{required_options.inspect} instead (#{caller[2]})"
options.update(required_options)
end

@required = options.fetch(:required, true)
Expand Down
7 changes: 4 additions & 3 deletions lib/dm-core/property.rb
Expand Up @@ -802,9 +802,10 @@ def initialize(model, name, type, options = {})
warn ":size option is deprecated, specify :min and :max instead (#{caller_method})"
end
elsif options.key?(:nullable)
# :required is preferable to :allow_nil, but :nullable maps precisely to :allow_nil
warn ":nullable option is deprecated, use :required instead (#{caller_method})"
options[:allow_nil] = options.delete(:nullable)
nullable_options = options.only(:nullable)
required_options = { :required => !options.delete(:nullable) }
warn "#{nullable_options.inspect} is deprecated, use #{required_options.inspect} instead (#{caller_method})"
options.update(required_options)
end

assert_valid_options(options)
Expand Down

0 comments on commit 5f9a0b5

Please sign in to comment.