Class: Runcible::Resources::Role

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

Overview

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

This class inherits a constructor from Runcible::Base

Class Method Details

.path(id = nil) ⇒ String

Generates the API path for Roles

Parameters:

  • id (String) (defaults to: nil)

    the ID of the role

Returns:

  • (String)

    the role path, may contain the ID if passed



34
35
36
# File 'lib/runcible/resources/role.rb', line 34

def self.path(id=nil)
  (id == nil) ? "roles/" : "roles/#{id}/" 
end

Instance Method Details

#add(id, login) ⇒ RestClient::Response

Adds a user to a role

Parameters:

  • id (String)

    the ID of the role

  • login (String)

    the login of the user being added

Returns:

  • (RestClient::Response)


43
44
45
46
# File 'lib/runcible/resources/role.rb', line 43

def add(id, )
  required = required_params(binding.send(:local_variables), binding, ["id"])
  call(:post, "#{path(id)}users/", :payload => { :required => required })
end

#remove(id, login) ⇒ RestClient::Response

Removes a user from a role

Parameters:

  • id (String)

    the ID of the role

  • login (String)

    the login of the user being removed

Returns:

  • (RestClient::Response)


53
54
55
# File 'lib/runcible/resources/role.rb', line 53

def remove(id, )
  call(:delete, "#{path(id)}users/#{}/")
end