class RHC::Rest::Mock::MockRestDomain

Public Class Methods

new(client, id) click to toggle source
# File lib/rhc/rest/mock.rb, line 545
def initialize(client, id)
  super({}, client)
  @id = id
  @applications = []
  self.attributes = {:links => mock_response_links(mock_domain_links('mock_domain_0'))}
end

Public Instance Methods

add_application(name, type=nil, scale=nil, gear_profile='default', git_url=nil) click to toggle source
# File lib/rhc/rest/mock.rb, line 564
def add_application(name, type=nil, scale=nil, gear_profile='default', git_url=nil)
  if type.is_a?(Hash)
    scale = type[:scale]
    gear_profile = type[:gear_profile]
    git_url = type[:initial_git_url]
    type = Array(type[:cartridges] || type[:cartridge])
  end
  a = MockRestApplication.new(client, name, type, self, scale, gear_profile, git_url)
  builder = @applications.find{ |app| app.cartridges.map(&:name).any?{ |s| s =~ %r^jenkins-[\d\.]+$/ } }
  a.building_app = builder.name if builder
  @applications << a
  a.add_message("Success")
  a
end
applications(*args) click to toggle source
# File lib/rhc/rest/mock.rb, line 579
def applications(*args)
  @applications
end
destroy() click to toggle source
# File lib/rhc/rest/mock.rb, line 557
def destroy
  raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty?
  client.domains.delete_if { |d| d.id == @id }

  @applications = nil
end
update(id) click to toggle source
# File lib/rhc/rest/mock.rb, line 552
def update(id)
  @id = id
  self
end