Class: Prmd::UrlGenerator::Generators::JSON Private

Inherits:
Object
  • Object
show all
Defined in:
lib/prmd/url_generators/generators/json.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

JSON URL Generator

Class Method Summary collapse

Class Method Details

.generate(params) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • params (Hash<Symbol, Object>)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/prmd/url_generators/generators/json.rb', line 14

def self.generate(params)
  data = {}
  data.merge!(params[:schema].schema_example(params[:link]['schema']))

  result = []
  data.sort_by {|k,_| k.to_s }.each do |key, values|
    [values].flatten.each do |value|
      result << [key.to_s, CGI.escape(value.to_s)].join('=')
    end
  end

  result
end