Class: JsonSchemaRails::Loaders::Directory

Inherits:
Base
  • Object
show all
Defined in:
lib/json_schema_rails/loaders/directory.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#cache

Instance Method Summary collapse

Methods inherited from Base

#cache?, #clear, #load_schema

Constructor Details

#initialize(path, options = {}) ⇒ Directory

Returns a new instance of Directory.



6
7
8
9
10
# File 'lib/json_schema_rails/loaders/directory.rb', line 6

def initialize(path, options = {})
  @path     = path
  @extnames = options.delete(:extnames) { %w(.yml .yaml .json) }
  super(options)
end

Instance Attribute Details

#extnamesObject

Returns the value of attribute extnames.



4
5
6
# File 'lib/json_schema_rails/loaders/directory.rb', line 4

def extnames
  @extnames
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/json_schema_rails/loaders/directory.rb', line 4

def path
  @path
end

Instance Method Details

#load_schema!(schema_path) ⇒ Object



12
13
14
15
16
17
# File 'lib/json_schema_rails/loaders/directory.rb', line 12

def load_schema!(schema_path)
  with_cache(schema_path) do
    file_path = lookup_schema_file(schema_path) or raise SchemaNotFound
    load_schema_file(file_path)
  end
end