Class: Yori::Schema::V3::Paths

Inherits:
Yori::SchemaBase show all
Defined in:
lib/yori/schema/v3/paths.rb

Overview

Paths

Holds the relative paths to the individual endpoints and their operations.
The path is appended to the URL from the Server Object in order to construct the full URL.
The Paths MAY be empty, due to ACL constraints.

Instance Attribute Summary

Attributes inherited from Yori::SchemaBase

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Yori::SchemaBase

eval_class!, eval_hash!, eval_input!, #ref, #validate!, #validator

Class Method Details

.register_path(id, path, value = nil, &block) ⇒ Object



35
36
37
38
39
# File 'lib/yori/schema/v3/paths.rb', line 35

def register_path(id, path, value = nil, &block)
  @registered_path ||= {}
  @registered_path[id] ||= {}
  @registered_path[id][path] = proc { path(path, value, &block) }
end

.registered_pathObject



31
32
33
# File 'lib/yori/schema/v3/paths.rb', line 31

def registered_path
  @registered_path ||= {}
end

Instance Method Details

#merge_registered!Object



24
25
26
27
28
# File 'lib/yori/schema/v3/paths.rb', line 24

def merge_registered!
  self.class.registered_path[id]&.each do |_path, block|
    instance_eval(&block)
  end
end

#pathObject



19
20
21
22
# File 'lib/yori/schema/v3/paths.rb', line 19

def path(path_temp, value = nil, &block)
  path_temp = '/' + path_temp unless path_temp.start_with?('/')
  self[path_temp] = self.class.eval_input!(Yori::Schema::V3::PathItem, id, value, &block)
end