lib/videojuicer/resource/property_registry.rb in vj-sdk-0.6.4 vs lib/videojuicer/resource/property_registry.rb in vj-sdk-0.6.5
- old
+ new
@@ -43,11 +43,12 @@
end
def attributes=(arg)
raise ArgumentError, "Attributes must be set as a Hash" unless arg.is_a?(Hash)
arg.each do |key, value|
- self.send("#{key}=", value)
+ #set any attributes, ignoring all those that are invalid
+ self.send("#{key}=", value) rescue invalid_attributes[key] = value
end
end
# Sets the attributes to their default values, marking only those values with defaults as being dirty.
def set_default_attributes
@@ -120,10 +121,11 @@
# Takes what is normally a string and coerces it into the correct object type for the
# attribute's actual type.
def coerce_value(key, value)
return value unless value
klass = self.class.attributes[key][:class]
+
if value.is_a?(String) and value.any?
# In-built types
if klass.kind_of?(Videojuicer::Resource::Types::Base)
return klass.new(value).dump
end
@@ -156,9 +158,13 @@
self.class.attributes.select {|name, props| props[:writer] != :public}.each do |name, props|
attrs.delete name
end
attrs.delete(:id)
attrs
+ end
+
+ def invalid_attributes
+ @invalid_attributes ||= {}
end
module SingletonMethods
# Registers an attribute using a datamapper-style syntax.
\ No newline at end of file