Anonymous casted model properties no longer require block parameter

This commit is contained in:
Sam Lown 2011-02-05 22:38:22 +01:00
parent 1ccb96bf56
commit 1019a44d26
5 changed files with 27 additions and 6 deletions

View file

@ -156,7 +156,11 @@ module CouchRest
type = Class.new(Hash) do
include CastedModel
end
type.class_eval { yield type }
if block.arity == 1 # Traditional, with options
type.class_eval { yield type }
else
type.instance_exec(&block)
end
type = [type] # inject as an array
end
property = Property.new(name, type, options)