Class: Idcf::JsonHyperSchema::Expands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/idcf/json_hyper_schema/expands/base.rb

Overview

json schema expand json schema v4

Direct Known Subclasses

V4

Constant Summary collapse

FULL_HREF_REGEXP =
Regexp.new('\A[a-zA-Z]*:?//').freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(global_access: true) ⇒ Base

initialize

Parameters:

  • global_access (Boolean) (defaults to: true)

    Is an external reference performed?



18
19
20
21
22
23
24
# File 'lib/idcf/json_hyper_schema/expands/base.rb', line 18

def initialize(global_access: true)
  @definition_ids = {}
  @options        =
    {
      global_access: global_access
    }
end

Instance Attribute Details

#definition_idsObject (readonly)

Returns the value of attribute definition_ids.



10
11
12
# File 'lib/idcf/json_hyper_schema/expands/base.rb', line 10

def definition_ids
  @definition_ids
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/idcf/json_hyper_schema/expands/base.rb', line 10

def options
  @options
end

#originObject (readonly)

Returns the value of attribute origin.



10
11
12
# File 'lib/idcf/json_hyper_schema/expands/base.rb', line 10

def origin
  @origin
end

#schemaObject (readonly)

Returns the value of attribute schema.



10
11
12
# File 'lib/idcf/json_hyper_schema/expands/base.rb', line 10

def schema
  @schema
end

Instance Method Details

#do!(schema) ⇒ Hash

do

Parameters:

  • schema (Hash)

Returns:

  • (Hash)

Raises:



31
32
33
34
35
36
37
38
# File 'lib/idcf/json_hyper_schema/expands/base.rb', line 31

def do!(schema)
  raise 'schema is not hash' unless schema.class == Hash
  target          = schema.deep_dup
  @origin         = schema.deep_dup
  @definition_ids = delete_id(make_ids(target))
  @schema         = exp(target)
  @schema
end

#find(path) ⇒ Object

ref find

Parameters:

  • path (String)

Returns:

  • Mixed



44
45
46
47
48
49
50
51
# File 'lib/idcf/json_hyper_schema/expands/base.rb', line 44

def find(path)
  if path =~ FULL_HREF_REGEXP
    return path unless @options[:global_access]
    global_find(path)
  else
    local_search(path)
  end
end