Class: Domain
- Inherits:
-
OpenShift::UserModel
- Object
- OpenShift::UserModel
- Domain
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/domain.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#user ⇒ Object
Returns the value of attribute user.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
- .find(user, id) ⇒ Object
- .find_all(user, namespace = nil) ⇒ Object
- .get(user, id) ⇒ Object
- .hash_to_obj(hash) ⇒ Object
- .namespace_available?(namespace) ⇒ Boolean
Instance Method Summary collapse
- #delete ⇒ Object
- #delete_dns ⇒ Object
- #hasAccess?(user) ⇒ Boolean
- #hasFullAccess?(user) ⇒ Boolean
-
#initialize(namespace = nil, user = nil) ⇒ Domain
constructor
A new instance of Domain.
- #save ⇒ Object
Constructor Details
Instance Attribute Details
#namespace ⇒ Object
Returns the value of attribute namespace.
4 5 6 |
# File 'app/models/domain.rb', line 4 def namespace @namespace end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'app/models/domain.rb', line 4 def user @user end |
#uuid ⇒ Object
Returns the value of attribute uuid.
4 5 6 |
# File 'app/models/domain.rb', line 4 def uuid @uuid end |
Class Method Details
.find(user, id) ⇒ Object
48 49 50 51 52 53 |
# File 'app/models/domain.rb', line 48 def self.find(user, id) domain = super(user.login, id) domain.user = user if domain return nil unless domain domain end |
.find_all(user, namespace = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/domain.rb', line 55 def self.find_all(user, namespace=nil) domains = super(user.login) unless namespace user.domains = domains return domains else filtered_domains = nil domains.each do |domain| if domain.namespace == namespace filtered_domains.push(domain) end end return filtered_domains end end |
.get(user, id) ⇒ Object
71 72 73 74 75 76 |
# File 'app/models/domain.rb', line 71 def self.get(user, id) user.domains.each do |domain| return domain if domain.namespace == id end if user.domains return nil end |
.hash_to_obj(hash) ⇒ Object
105 106 107 108 |
# File 'app/models/domain.rb', line 105 def self.hash_to_obj(hash) domain = super(hash) domain end |
.namespace_available?(namespace) ⇒ Boolean
99 100 101 102 103 |
# File 'app/models/domain.rb', line 99 def self.namespace_available?(namespace) Rails.logger.debug "Checking to see if namesspace #{namespace} is available" dns_service = OpenShift::DnsService.instance return dns_service.namespace_available?(namespace) end |
Instance Method Details
#delete ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'app/models/domain.rb', line 88 def delete Rails.logger.debug "Deleting domain #{self.namespace} uuid #{self.uuid}" resultIO = ResultIO.new delete_dns super(user.login) Rails.logger.debug "notifying the domain observer of domain delete" notify_observers(:after_domain_destroy) Rails.logger.debug "done notifying the domain observer" resultIO end |
#delete_dns ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'app/models/domain.rb', line 78 def delete_dns dns_service = OpenShift::DnsService.instance begin dns_service.deregister_namespace(self.namespace) dns_service.publish ensure dns_service.close end end |
#hasAccess?(user) ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'app/models/domain.rb', line 32 def hasAccess?(user) #TODO #if user.domains.include? self.uuid return true #end #return false end |
#hasFullAccess?(user) ⇒ Boolean
40 41 42 43 44 45 46 |
# File 'app/models/domain.rb', line 40 def hasFullAccess?(user) #TODO #if self.user.login == user.login return true #end #return false end |
#save ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/domain.rb', line 13 def save resultIO = ResultIO.new created = false if not persisted? resultIO.append(create()) created = true else resultIO.append(update()) end begin super(self.user.login) rescue delete_dns if created raise end resultIO end |