Class responsible for holding request parameters
Constant Summary collapse[:accept, :media, :data, :raw, :headers]
Create empty hash.
Get accept header.
Extract request data from parameters.
A new instance of ParamsHash.
Extract and parse media type param.
Update hash with default parameters for non existing keys.
Configuration options from request.
Filter out request params.
Base64 encode string removing newline characters.
#deep_key?, #deep_keys, #deep_merge, #deep_merge!, #except, #except!, #serialize, #symbolize_keys, #symbolize_keys!
Constructor Details #initialize(hash) ⇒ ParamsHashReturns a new instance of ParamsHash.
17 18 19
# File 'lib/github_api/params_hash.rb', line 17 def initialize(hash) super(normalize!(Hash[hash])) endClass Method Details .empty ⇒ Object
24 25 26
# File 'lib/github_api/params_hash.rb', line 24 def self.empty new({}) endInstance Method Details #accept ⇒ Object
40 41 42 43 44 45
# File 'lib/github_api/params_hash.rb', line 40 def accept if key?('accept') then self['accept'] elsif key?('media') then media else nil end end#data ⇒ Object
Extract request data from parameters
50 51 52 53 54 55 56
# File 'lib/github_api/params_hash.rb', line 50 def data if key?('data') && !self['data'].nil? self['data'] else request_params end end#encoder ⇒ Object
58 59 60 61 62 63 64
# File 'lib/github_api/params_hash.rb', line 58 def encoder if key?('encoder') && self['encoder'] self['encoder'] else {} end end#media ⇒ Object
Extract and parse media type param
[.version].param[+json]
33 34 35
# File 'lib/github_api/params_hash.rb', line 33 def media parse(delete('media')) end#merge_default(defaults) ⇒ Object
Update hash with default parameters for non existing keys
84 85 86 87 88 89 90 91
# File 'lib/github_api/params_hash.rb', line 84 def merge_default(defaults) if defaults && !defaults.empty? defaults.each do |key, value| self[key] = value unless self.key?(key) end end self end#options ⇒ Hash
Configuration options from request
71 72 73 74 75 76 77 78 79 80
# File 'lib/github_api/params_hash.rb', line 71 def options opts = fetch('options', {}) = fetch('headers', {}) if value = accept [:accept] = value end opts[:raw] = key?('raw') ? self['raw'] : false opts[:headers] = unless .empty? opts end#request_params ⇒ Object
Filter out request params
109 110 111 112 113
# File 'lib/github_api/params_hash.rb', line 109 def request_params to_hash.select do |key, value| !REQUEST_PARAMS.include?(key.to_sym) end end#strict_encode64(key) ⇒ Object
Base64 encode string removing newline characters
96 97 98 99 100 101 102 103 104
# File 'lib/github_api/params_hash.rb', line 96 def strict_encode64(key) value = self[key] encoded = if Base64.respond_to?(:strict_encode64) Base64.strict_encode64(value) else [value].pack('m0') end self[key] = encoded.delete("\n\r") end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4