Class: Onering::API::Auth
- Inherits:
-
Onering::API
- Object
- Onering::API
- Onering::API::Auth
- Defined in:
- lib/onering/plugins/authentication.rb
Constant Summary
Constants inherited from Onering::API
DEFAULT_BASE, DEFAULT_CLIENT_KEY, DEFAULT_CLIENT_PEM, DEFAULT_PATH, DEFAULT_VALIDATION_PEM
Constants included from Util
Instance Attribute Summary
Attributes inherited from Onering::API
Instance Method Summary collapse
- #_check_type(type) ⇒ Object
- #list(type, field = 'id', options = { :unique => true, :sort => true, :filter => nil }) ⇒ Object
- #save(type, id, data) ⇒ Object
- #show(type, id = 'current') ⇒ Object
Methods inherited from Onering::API
#_default_param, #_setup_auth, #_setup_auth_token, #connect, #delete, #get, #initialize, #method_missing, #post, #put, #request, #status
Methods included from Util
#fact, #gem_path, #http_status, #make_filter
Constructor Details
This class inherits a constructor from Onering::API
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Onering::API
Instance Method Details
#_check_type(type) ⇒ Object
4 5 6 7 8 |
# File 'lib/onering/plugins/authentication.rb', line 4 def _check_type(type) raise "Invalid authentication module object '#{type}'" unless %w{ users groups capabilities }.include?(type.to_s) end |
#list(type, field = 'id', options = { :unique => true, :sort => true, :filter => nil }) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/onering/plugins/authentication.rb', line 15 def list(type, field='id', ={ :unique => true, :sort => true, :filter => nil }) _check_type(type) rv = get("#{type}/list").parsed_response.collect{|i| i[field.to_s] } rv = rv.uniq if [:unique] rv = rv.sort if [:sort] rv end |
#save(type, id, data) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/onering/plugins/authentication.rb', line 27 def save(type, id, data) _check_type(type) post("#{type}/#{id}", { :body => data }).parsed_response end |
#show(type, id = 'current') ⇒ Object
10 11 12 13 |
# File 'lib/onering/plugins/authentication.rb', line 10 def show(type, id='current') _check_type(type) get("#{type}/#{id}").parsed_response end |