lib/hashme/properties.rb in hashme-0.2.6 vs lib/hashme/properties.rb in hashme-0.3.0
- old
+ new
@@ -12,11 +12,11 @@
end
def set_attribute(name, value)
property = get_property(name)
if property
- value = property.build(self, value)
+ value = property.build(value)
if value.nil?
delete(property.name)
else
self[property.name] = value
end
@@ -43,13 +43,13 @@
def set_attributes(attrs = {})
attrs.each do |key, value|
set_attribute(key, value)
end
end
-
+
private
-
+
def get_property(name)
self.class.properties[name.to_sym]
end
module ClassMethods
@@ -66,10 +66,10 @@
protected
def define_property_methods(property)
# Getter
define_method(property.name) do
- get_attribute(property.name) || property.default
+ get_attribute(property.name)
end
# Setter
define_method "#{property.name}=" do |value|
set_attribute(property.name, value)
end