Class: Runcible::Resources::Role
- Defined in:
- lib/runcible/resources/role.rb
Overview
Instance Attribute Summary
Attributes inherited from Base
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, #exception_to_log, #format_payload_json, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #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
9 10 11 |
# File 'lib/runcible/resources/role.rb', line 9 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
18 19 20 21 |
# File 'lib/runcible/resources/role.rb', line 18 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
28 29 30 |
# File 'lib/runcible/resources/role.rb', line 28 def remove(id, login) call(:delete, "#{path(id)}users/#{login}/") end |