Sha256: 37c00fcbb96ff0935ff004d3029a76c91cfb35e7f9bbe0c27fcfd54910ed89a5

Contents?: true

Size: 919 Bytes

Versions: 28

Compression:

Stored size: 919 Bytes

Contents

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

        def get(type, id='current')
          _check_type(type)
          request("#{type}/#{id}")
        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 save(type, id, data)
          _check_type(type)
          request("#{type}/#{id}", {
            :method => :post,
            :data   => data
          })
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
onering-client-0.0.46 lib/onering/plugins/authentication.rb
onering-client-0.0.45 lib/onering/plugins/authentication.rb
onering-client-0.0.44 lib/onering/plugins/authentication.rb
onering-client-0.0.43 lib/onering/plugins/authentication.rb
onering-client-0.0.42 lib/onering/plugins/authentication.rb
onering-client-0.0.41 lib/onering/plugins/authentication.rb
onering-client-0.0.40 lib/onering/plugins/authentication.rb
onering-client-0.0.39 lib/onering/plugins/authentication.rb
onering-client-0.0.37 lib/onering/plugins/authentication.rb
onering-client-0.0.36 lib/onering/plugins/authentication.rb
onering-client-0.0.35 lib/onering/plugins/authentication.rb
onering-client-0.0.34 lib/onering/plugins/authentication.rb
onering-client-0.0.33 lib/onering/plugins/authentication.rb
onering-client-0.0.32 lib/onering/plugins/authentication.rb
onering-client-0.0.30 lib/onering/plugins/authentication.rb
onering-client-0.0.29 lib/onering/plugins/authentication.rb
onering-client-0.0.28 lib/onering/plugins/authentication.rb
onering-client-0.0.27 lib/onering/plugins/authentication.rb
onering-client-0.0.26 lib/onering/plugins/authentication.rb
onering-client-0.0.25 lib/onering/plugins/authentication.rb