Class: Puree::Extractor::Resource

Inherits:
Object
  • Object
show all
Includes:
API::Authentication
Defined in:
lib/puree/extractor/resource.rb

Overview

Resource extractor.

Instance Method Summary collapse

Constructor Details

#initialize(config, bleeding: true) ⇒ Resource

Returns a new instance of Resource.

Parameters:

  • bleeding (Boolean) (defaults to: true)
  • config (Hash)

    a customizable set of options

Options Hash (config):

  • :url (String)

    The URL of the Pure host.

  • :username (String)

    The username of the Pure host account.

  • :password (String)

    The password of the Pure host account.



12
13
14
15
# File 'lib/puree/extractor/resource.rb', line 12

def initialize(config, bleeding: true)
  @latest_api = bleeding
  configure_api config
end

Instance Method Details

#get(uuid: nil, id: nil) ⇒ Puree::Model::Resource subclass? Also known as: find

Get a resource.

Parameters:

  • uuid (String) (defaults to: nil)
  • id (String) (defaults to: nil)

Returns:



22
23
24
25
26
27
28
29
# File 'lib/puree/extractor/resource.rb', line 22

def get(uuid: nil, id: nil)
  raise 'Cannot perform a request without a configuration' if @config.nil?
  @response = @request.get uuid:           uuid,
                           id:             id,
                           latest_api:     @latest_api,
                           resource_type:  @resource_type
  set_content @response.body
end