Class: Domain

Inherits:
RestApi::Base show all
Defined in:
app/models/domain.rb

Overview

The REST API model object representing the domain, which may contain multiple applications.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RestApi::Base

alias_attribute, aliased_attributes, allow_anonymous?, #as, #as=, #assign_attributes, attr_alters, #attributes=, calculated_attributes, #clone, configuration=, connection, custom_id, delete, #dup, #duplicate_errors, element_path, exception_for_code, find, get, #get, #has_exit_code?, headers, #initialize, #load, #load_remote_errors, on_exit_code, #raise_on_invalid, remote_errors_for, #remote_results, #save!, #save_with_change_tracking, shared_connection, singleton?, #to_json, translate_api_error, use_patch_on_update?, #valid?

Methods included from ActiveResource::Associations

#belongs_to, #has_many, #has_one

Constructor Details

This class inherits a constructor from RestApi::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RestApi::Base

Class Method Details

.find_one(options) ⇒ Object

FIXME: Temporary until multiple domains are supported



39
40
41
42
43
# File 'app/models/domain.rb', line 39

def self.find_one(options)
  domain = first(options)
  raise RestApi::ResourceNotFound.new(model_name, nil) if domain.nil?
  domain
end

Instance Method Details

#applicationsObject



17
18
19
# File 'app/models/domain.rb', line 17

def applications
  @applications ||= Application.find :all, { :params => { :domain_id => self.id }, :as => as }
end

#destroy_recursiveObject



34
35
36
# File 'app/models/domain.rb', line 34

def destroy_recursive
  connection.delete(element_path({:force => true}.merge(prefix_options)), self.class.headers)
end

#find_application(name) ⇒ Object



20
21
22
# File 'app/models/domain.rb', line 20

def find_application(name)
  Application.find name, { :params => { :domain_id => self.id }, :as => as}
end

#reloadObject

FIXME should have an observer pattern that clears cached associations on reload



25
26
27
28
# File 'app/models/domain.rb', line 25

def reload
  @applications = nil
  super
end

#userObject



30
31
32
# File 'app/models/domain.rb', line 30

def user
  User.find :one, :as => as
end