lib/scrivito/model_library.rb in scrivito_sdk-0.66.0 vs lib/scrivito/model_library.rb in scrivito_sdk-0.70.0.rc1
- old
+ new
@@ -75,12 +75,18 @@
def load_models_from_paths(type, base_class)
paths.map { |path| load_models_from_path(type, path, base_class) }.flatten
end
def load_models_from_path(type, path, base_class)
- Dir["#{path}/**/*_#{type}.rb"].map do |file_path|
+ candidates_from_path(type, path).map do |file_path|
load_model(file_path.gsub(path, '').gsub('.rb', '').classify, base_class)
end
+ end
+
+ def candidates_from_path(type, path)
+ result = Dir["#{path}/**/*_#{type}.rb"]
+ result += Dir["#{path}/**/page.rb"] if type == 'page'
+ result
end
def load_model(class_name, base_class)
model_class = class_name.constantize
model_class if model_class.ancestors.include?(base_class)