Class: Runcible::Resources::Role
- Defined in:
- lib/runcible/resources/role.rb
Overview
Class Method Summary collapse
-
.path(id = nil) ⇒ String
Generates the API path for Roles.
Instance Method Summary collapse
-
#add(id, login) ⇒ RestClient::Response
Adds a user to a role.
-
#remove(id, login) ⇒ RestClient::Response
Removes a user from a role.
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
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
43 44 45 46 |
# File 'lib/runcible/resources/role.rb', line 43 def add(id, login) 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
53 54 55 |
# File 'lib/runcible/resources/role.rb', line 53 def remove(id, login) call(:delete, "#{path(id)}users/#{login}/") end |