lib/relaxo/model/properties/attribute.rb in relaxo-model-0.4.3 vs lib/relaxo/model/properties/attribute.rb in relaxo-model-0.4.4
- old
+ new
@@ -51,20 +51,18 @@
self.new(klass, &proc)
end
def initialize(klass, &serialization)
@klass = klass
-
- raise ArgumentError.new("Klass doesn't respond to parse!") unless @klass.respond_to? :parse
end
def convert_to_primative(value)
- value.to_s
+ @klass.dump(value)
end
def convert_from_primative(database, value)
- @klass.parse(value)
+ @klass.load(value)
end
end
Required = Attribute
@@ -76,18 +74,18 @@
def initialize(klass)
@klass = klass
end
def convert_to_primative(value)
- if value == nil || value == ''
+ if value.nil? or value.empty?
nil
else
@klass.convert_to_primative(value)
end
end
def convert_from_primative(database, value)
- if value == nil || value.empty?
+ if value.nil? or value.empty?
nil
else
@klass.convert_from_primative(database, value)
end
end