lib/hashme/properties.rb in hashme-0.2.0 vs lib/hashme/properties.rb in hashme-0.2.1

- old
+ new

@@ -50,11 +50,11 @@ def property(*args) # Prepare the property object and methods property = Property.new(*args) self.properties = properties.merge(property.name => property) define_property_methods(property) - + prepare_validation(property) property end protected @@ -64,9 +64,15 @@ get_attribute(property.name) || property.default end # Setter define_method "#{property.name}=" do |value| set_attribute(property.name, value) + end + end + + def prepare_validation(property) + if property.type.method_defined?(:valid?) + validates_casted_attributes property.name end end end