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

Commit

Permalink
Allow Property lazy context to be a Symbol or Array of Symbols
Browse files Browse the repository at this point in the history
[#962 state:resolved]
  • Loading branch information
dkubb committed Aug 18, 2009
1 parent 67fbf33 commit 1b8c662
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/dm-core/property.rb
Expand Up @@ -899,11 +899,16 @@ def assert_valid_options(options)
raise ArgumentError, "options[#{key.inspect}] must not be nil"
end

when :serial, :key, :nullable, :unique, :lazy, :auto_validation
when :serial, :key, :nullable, :unique, :auto_validation
unless value == true || value == false
raise ArgumentError, "options[#{key.inspect}] must be either true or false"
end

when :lazy
unless value == true || value == false || value.kind_of?(Symbol) || (value.kind_of?(Array) && value.all? { |val| val.kind_of?(Symbol) })
raise ArgumentError, "options[#{key.inspect}] must be either true, false, a Symbol or an Array of Symbols"
end

when :index, :unique_index
assert_kind_of "options[#{key.inspect}]", value, Symbol, Array, TrueClass

Expand Down
2 changes: 1 addition & 1 deletion spec/public/property_spec.rb
Expand Up @@ -20,7 +20,7 @@ class ::Image

property :md5hash, String, :key => true, :length => 32
property :title, String, :nullable => false, :unique => true
property :description, Text, :length => 1..1024, :lazy => true
property :description, Text, :length => 1..1024, :lazy => [ :detail ]

property :format, String, :default => 'jpeg'
# WxH, stored as a dumped Ruby pair
Expand Down

0 comments on commit 1b8c662

Please sign in to comment.