Module: Nonacat::Link

Defined in:
lib/nonacat.rb

Overview

a module for JSI instances whose content is a URL corresponding to an operation of the OpenAPI description

Instance Method Summary collapse

Instance Method Details

#get(**conf, &b) ⇒ Object



17
18
19
# File 'lib/nonacat.rb', line 17

def get(**conf, &b)
  get_request(**conf, &b).run
end

#get_request(**conf, &b) ⇒ Scorpio::Request

Returns:

  • (Scorpio::Request)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nonacat.rb', line 22

def get_request(**conf, &b)
  uri = JSI::URI[self]
  conf[:query_params] = [uri.query_values, conf.delete(:query_params), conf.delete('query_params')].inject(nil) { |c, p| c ? p ? c.merge(p) : c : p }
  GITHUB_API.operations.each do |operation|
    next if !operation.get?
    path_params = operation.uri_template.extract(operation.base_url.join(uri.merge(query: nil))) || next
    conf[:path_params] = [conf.delete(:path_params), conf.delete('path_params')].inject(path_params) { |c, p| p ? c.merge(p) : c }
    return operation.build_request(**conf, &b)
  end
  raise("no operation matched url: #{jsi_node_content}")
end

#jsi_as_child_default_as_jsiObject

see JSI::Base



13
14
15
# File 'lib/nonacat.rb', line 13

def jsi_as_child_default_as_jsi
  !jsi_node_content.nil?
end