Class: JsonSchemaRails::Loaders::Base

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

Direct Known Subclasses

Directory, HyperSchema, SchemaValidator::Loader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/json_schema_rails/loaders/base.rb', line 11

def initialize(options = {})
  @cache = options.fetch(:cache) { true }
end

Instance Attribute Details

#cache=(value) ⇒ Object (writeonly)

Sets the attribute cache

Parameters:

  • value

    the value to set the attribute cache to.



9
10
11
# File 'lib/json_schema_rails/loaders/base.rb', line 9

def cache=(value)
  @cache = value
end

Instance Method Details

#cache?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/json_schema_rails/loaders/base.rb', line 15

def cache?
  !!@cache
end

#clearObject



19
20
21
# File 'lib/json_schema_rails/loaders/base.rb', line 19

def clear
  cache_data.clear
end

#load_schema(schema_path) ⇒ Object



23
24
25
26
27
# File 'lib/json_schema_rails/loaders/base.rb', line 23

def load_schema(schema_path)
  load_schema!(schema_path)
rescue SchemaNotFound
  nil
end

#load_schema!(schema_path) ⇒ Object

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/json_schema_rails/loaders/base.rb', line 29

def load_schema!(schema_path)
  raise NotImplementedError
end