lib/onering/plugins/authentication.rb in onering-client-0.0.46 vs lib/onering/plugins/authentication.rb in onering-client-0.0.50
- old
+ new
@@ -1,39 +1,35 @@
-
module Onering
- module API
- class Auth < Base
- class<<self
- def _check_type(type)
- raise "Invalid authentication module object '#{type}'" unless %w{
- users groups capabilities
- }.include?(type.to_s)
- end
+ class API
+ class Auth < API
+ def _check_type(type)
+ raise "Invalid authentication module object '#{type}'" unless %w{
+ users groups capabilities
+ }.include?(type.to_s)
+ end
- def get(type, id='current')
- _check_type(type)
- request("#{type}/#{id}")
- end
+ def show(type, id='current')
+ _check_type(type)
+ get("#{type}/#{id}").parsed_response
+ end
- def list(type, field='id', options={
- :unique => true,
- :sort => true,
- :filter => nil
- })
- _check_type(type)
- rv = request("#{type}/list").collect{|i| i[field.to_s] }
- rv = rv.uniq if options[:unique]
- rv = rv.sort if options[:sort]
- rv
- end
+ def list(type, field='id', options={
+ :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 options[:unique]
+ rv = rv.sort if options[:sort]
+ rv
+ end
- def save(type, id, data)
- _check_type(type)
- request("#{type}/#{id}", {
- :method => :post,
- :data => data
- })
- end
+ def save(type, id, data)
+ _check_type(type)
+ post("#{type}/#{id}", {
+ :body => data
+ }).parsed_response
end
end
end
end