Class: Runcible::Resources::Unit

Inherits:
Base
  • Object
show all
Defined in:
lib/runcible/resources/unit.rb

Overview

Direct Known Subclasses

Extensions::Unit

Instance Attribute Summary

Attributes inherited from Base

#logs

Instance Method Summary collapse

Methods inherited from Base

#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #exception_to_log, #format_payload_json, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #logger, #process_response, #required_params

Constructor Details

This class inherits a constructor from Runcible::Base

Instance Method Details

#path(type) ⇒ String

Generates the API path for Units

Parameters:

  • type (String)

    the unit type

Returns:

  • (String)

    the unit search path



9
10
11
# File 'lib/runcible/resources/unit.rb', line 9

def path(type)
  "content/units/#{type}/search/"
end

#search(type, criteria, optional = {}) ⇒ RestClient::Response

Searches a given unit type based on criteria

Parameters:

  • type (String)

    the unit type

  • criteria (Hash)

    criteria object containing Mongo syntax

  • optional (Hash) (defaults to: {})

    container for all optional parameters

Returns:

  • (RestClient::Response)


19
20
21
# File 'lib/runcible/resources/unit.rb', line 19

def search(type, criteria, optional = {})
  call(:post, path(type), :payload => {:required => {:criteria => criteria}, :optional => optional})
end