Class: HammerCLIForemanWebhooks::CommandExtensions::Webhook
- Inherits:
-
HammerCLI::CommandExtensions
- Object
- HammerCLI::CommandExtensions
- HammerCLIForemanWebhooks::CommandExtensions::Webhook
- Defined in:
- lib/hammer_cli_foreman_webhooks/command_extensions/webhook.rb
Class Method Summary collapse
Class Method Details
.http_headers_from_json(data) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hammer_cli_foreman_webhooks/command_extensions/webhook.rb', line 29 def self.http_headers_from_json(data) return data unless data.is_a?(String) require 'json' begin JSON.parse(data).each_pair.each_with_object([]) do |(key, value), result| result << { name: key, value: value } end rescue JSON::ParserError [{}] end end |
.http_headers_to_json(headers) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/hammer_cli_foreman_webhooks/command_extensions/webhook.rb', line 22 def self.http_headers_to_json(headers) return headers unless headers.is_a?(Hash) require 'json' JSON.dump(headers) end |