lib/couchrest/model/properties.rb in couchrest_model-1.0.0 vs lib/couchrest/model/properties.rb in couchrest_model-1.1.0.beta
- old
+ new
@@ -154,10 +154,14 @@
type = options.delete(:type) || options.delete(:cast_as)
if block_given?
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)
create_property_getter(property)
create_property_setter(property) unless property.read_only == true