Module: Glassfrog::REST::Patch

Defined in:
lib/glassfrog/rest/patch.rb

Overview

Encapsulates all PATCH requests.

Class Method Summary collapse

Class Method Details

.formify(options, type) ⇒ Hash

Turns options into PATCH form.

Parameters:

  • options (Hash)

    Options to be formified.

  • type (Class)

    Class being targeted by the request.

Returns:

  • (Hash)

    Formified options.



26
27
28
29
30
31
32
# File 'lib/glassfrog/rest/patch.rb', line 26

def self.formify(options, type)
  options.keys.map do |key|
   { op: 'replace',
     path: type::PATH + '/0/' + key.to_s,
     value: options[key] }
  end
end

.patch(client, path, options) ⇒ Boolean

Sends a PATCH request.

Parameters:

  • client (Glassfrog::Client)

    Client that will send the request.

  • path (String)

    Path to send request to.

  • options (Hash)

    Options being sent in the request.

Returns:

  • (Boolean)

    Whether request was successful.



16
17
18
# File 'lib/glassfrog/rest/patch.rb', line 16

def self.patch(client, path, options)
  Glassfrog::REST::Request.new(client, :patch, path, options).perform
end