Method: SchemaTools::Modules::Read#read_all
- Defined in:
- lib/schema_tools/modules/read.rb
#read_all(path = nil) ⇒ Array<HashWithIndifferentAccess>
Read all available schemas from a given path(folder +subfolders) and return the found object definitions them as array. Also populates the registry
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/schema_tools/modules/read.rb', line 68 def read_all(path=nil) schemas = [] file_paths = if path [File.join(path, '*.json')] else [ File.join( SchemaTools.schema_path, '*.json'), File.join( SchemaTools.schema_path, '**/*', '*.json') ] end Dir.glob( file_paths ).each do |file| schema_name = File.basename(file, '.json').to_sym schemas << read(schema_name, path) end schemas.compact! schemas end |