Sha256: a97b2443f506dfe34a56c759eb7c07ef26c7a5a6ccece803b0bc9c4eec8626fc

Contents?: true

Size: 844 Bytes

Versions: 72

Compression:

Stored size: 844 Bytes

Contents

module Onering
  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 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 = 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)
        post("#{type}/#{id}", {
          :body   => data
        }).parsed_response
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 2 rubygems

Version Path
onering-client-0.0.81 lib/onering/plugins/authentication.rb
onering-client-0.0.80 lib/onering/plugins/authentication.rb
onering-client-0.0.79 lib/onering/plugins/authentication.rb
onering-client-0.0.78 lib/onering/plugins/authentication.rb
onering-client-0.0.77 lib/onering/plugins/authentication.rb
onering-client-0.0.76 lib/onering/plugins/authentication.rb
onering-client-0.0.75 lib/onering/plugins/authentication.rb
onering-client-0.0.74 lib/onering/plugins/authentication.rb
onering-client-0.0.73 lib/onering/plugins/authentication.rb
onering-client-0.0.72 lib/onering/plugins/authentication.rb
onering-client-0.0.71 lib/onering/plugins/authentication.rb
onering-client-0.0.70 lib/onering/plugins/authentication.rb
onering-client-0.0.69 lib/onering/plugins/authentication.rb
onering-client-0.0.68 lib/onering/plugins/authentication.rb
onering-client-0.0.67 lib/onering/plugins/authentication.rb
onering-client-0.0.66 lib/onering/plugins/authentication.rb
onering-client-0.0.65 lib/onering/plugins/authentication.rb
onering-client-0.0.64 lib/onering/plugins/authentication.rb
onering-client-0.0.63 lib/onering/plugins/authentication.rb
onering-client-0.0.62 lib/onering/plugins/authentication.rb