class RHC::Rest::Mock::MockRestDomain
Public Class Methods
new(client, id)
click to toggle source
Calls superclass method
RHC::Rest::Base.new
# File lib/rhc/rest/mock.rb, line 748 def initialize(client, id) super({}, client) @name = id @applications = [] self.attributes = {:links => mock_response_links(mock_domain_links(id))} init_members end
Public Instance Methods
add_application(name, type=nil, scale=nil, gear_profile='default', git_url=nil, region=nil)
click to toggle source
# File lib/rhc/rest/mock.rb, line 768 def add_application(name, type=nil, scale=nil, gear_profile='default', git_url=nil, region=nil) if type.is_a?(Hash) scale = type[:scale] gear_profile = type[:gear_profile] git_url = type[:initial_git_url] tags = type[:tags] region = type[:region] type = Array(type[:cartridges] || type[:cartridge]) end a = MockRestApplication.new(client, name, type, self, scale, gear_profile, git_url, nil, region) builder = @applications.find{ |app| app.cartridges.map(&:name).any?{ |s| s =~ /^jenkins-[\d\.]+$/ } } a.building_app = builder.name if builder @applications << a a.add_message("Success") a end
add_member(member)
click to toggle source
# File lib/rhc/rest/mock.rb, line 795 def add_member(member) (@members ||= []) << member (attributes['members'] ||= []) << member.attributes self end
applications(*args)
click to toggle source
# File lib/rhc/rest/mock.rb, line 785 def applications(*args) @applications end
destroy(force=false)
click to toggle source
# File lib/rhc/rest/mock.rb, line 761 def destroy(force=false) raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty? or force.present? client.domains.delete_if { |d| d.name == @name } @applications = nil end
init_members()
click to toggle source
# File lib/rhc/rest/mock.rb, line 789 def init_members @members ||= [] attributes['members'] ||= [] self end
rename(id)
click to toggle source
# File lib/rhc/rest/mock.rb, line 756 def rename(id) @name = id self end