class Fog::Proxmox::Identity::Domain

class Domain model authentication

Public Class Methods

new(new_attributes = {}) click to toggle source
Calls superclass method
# File lib/fog/identity/proxmox/models/domain.rb, line 28
def initialize(new_attributes = {})
  initialize_type(new_attributes)
  super(new_attributes)
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/identity/proxmox/models/domain.rb, line 38
def destroy
  requires :realm
  service.delete_domain(realm)
  true
end
save(new_attributes = {}) click to toggle source
# File lib/fog/identity/proxmox/models/domain.rb, line 33
def save(new_attributes = {})
  service.create_domain(type.attributes.merge(new_attributes).merge(attributes.reject { |attribute| [:type].include? attribute }))
  reload
end
update() click to toggle source
# File lib/fog/identity/proxmox/models/domain.rb, line 44
def update
  requires :realm
  service.update_domain(realm, type.attributes.merge(attributes).reject { |attribute| [:type, :realm].include? attribute })
  reload
end

Private Instance Methods

initialize_type(new_attributes = {}) click to toggle source
# File lib/fog/identity/proxmox/models/domain.rb, line 52
def initialize_type(new_attributes = {})
  if new_attributes.has_key? :realm
    realm = new_attributes.delete(:realm)
  elsif new_attributes.has_key? 'realm'              
    realm = new_attributes.delete('realm')
  end
  attributes[:type] = Fog::Proxmox::Identity::DomainType.new(new_attributes)
  new_attributes.delete_if { |new_attribute| attributes[:type].attributes.has_key? new_attribute.to_sym }
  new_attributes.store(:realm, realm)
end