lib/unimatrix/parser.rb in unimatrix-2.5.0 vs lib/unimatrix/parser.rb in unimatrix-2.5.1
- old
+ new
@@ -67,11 +67,11 @@
Resource.find_by_type_name( self.type_name )
if resource_class.present?
relations = name == self.name ?
self.parse_associations( attributes ) : []
- resource = resource_class.new( attributes, relations )
+ resource = resource_class.build( attributes, relations )
end
end
@resources_mutex[ name ].delete( object_key )
@@ -93,26 +93,26 @@
return nil if @resource_index_mutex[ name ].include?( key )
@resource_index_mutex[ name ].push( key )
result = nil
resource_attributes = resource_attribute_index[ name ][ key ]
-
- if resource_attributes.present?
- parse_nested_attributes( resource_attributes )
-
- resource_class = find_resource_class_by_type_name(
- resource_attributes[ 'type_name' ],
- options[ 'type_name' ]
- )
-
- if resource_class.present?
- result = resource_class.new(
- resource_attributes,
- self.resource_associations_by( name, key )
- )
+
+ if resource_attributes.present?
+
+ parse_nested_attributes( resource_attributes )
+
+ resource_class = find_resource_class_by_type_name(
+ resource_attributes[ 'type_name' ],
+ options[ 'type_name' ]
+ )
+ if resource_class.present?
+ result = resource_class.build(
+ resource_attributes,
+ self.resource_associations_by( name, key )
+ )
+ end
end
- end
# unlock the resource index for this name/key combination
@resource_index_mutex[ name ].delete( key )
result
@@ -126,10 +126,10 @@
unless resource_class.present?
resource_class = Resource.find_by_type_name( option_type_name )
end
resource_class
end
-
+
def resource_associations_by( name, key )
result = Hash.new { | hash, key | hash[ key ] = [] }
associations = self.associations
if associations && associations.include?( name )
association = associations[ name ].detect do | association |