lib/dir_model/import.rb in dir_model-0.6.1 vs lib/dir_model/import.rb in dir_model-0.6.2
- old
+ new
@@ -39,18 +39,24 @@
def find_relations(dir_model, path, context)
if dir_model.has_relations?
if dir_model.has_one?
child = search(path, context) do |_path, _context|
- dir_model.append_dir_model(_path.current_path, index: _path.index, context: _context)
+ related_dir_model = nil
+ dir_model.has_one.each do |name, options|
+ related_dir_model = dir_model.append_dir_model(_path.current_path, index: _path.index, context: _context, relation_name: name, relation_options: options)
+ end
+ related_dir_model
end.first
+ # Recursive call on children
find_relations(child, path, context) if child
end
if dir_model.has_many?
children = search(path, context) do |_path, _context|
dir_model.append_dir_models(_path.current_path, index: _path.index, context: _context)
end
+ # Recursive call on children
children.each { |_child| find_relations(_child, path, context) }
end
end
end
@@ -83,10 +89,10 @@
@_match = (source_path||'').match(get_regexp)
end
def get_regexp
if foreign_value
- Regexp.new(self.class.options[:regex].call(Regexp.quote(foreign_value)), Regexp::IGNORECASE)
+ Regexp.new(self.class.options[:regex].call(foreign_value), Regexp::IGNORECASE)
else
self.class.options[:regex].call
end
end
end