Class: VMCAppfog::Unmap

Inherits:
VMC::CLI
  • Object
show all
Defined in:
lib/appfog-vmc-plugin/commands/unmap.rb

Instance Method Summary collapse

Instance Method Details

#unmapObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/appfog-vmc-plugin/commands/unmap.rb', line 9

def unmap
  app = input[:app]

  fail "No urls to unmap." if app.urls.empty?

  url = input[:url, (app.urls.map{|url| OpenStruct.new({name: url})})] unless input[:all]
  if url.is_a? String
    url = OpenStruct.new({name: url})
  end

  with_progress("Updating #{c(app.name, :name)}") do |s|
    if input[:all]
      app.urls = []
    else

      simple = url.name.sub(/^https?:\/\/(.*)\/?/i, '\1')

      unless app.urls.delete(simple)
        fail "URL #{url.name} is not mapped to this application."
      end
    end

    app.update!
  end
end