Class: Couchup::Commands::Drop

Inherits:
Object
  • Object
show all
Includes:
Couchup::CommandExtensions
Defined in:
lib/couchup/commands/drop.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Couchup::CommandExtensions

included, #needs_db!

Class Method Details

.describeObject



13
14
15
16
17
18
19
# File 'lib/couchup/commands/drop.rb', line 13

def self.describe
  {
    :description => "Drops specified object from couchdb",
    :usage => "drop [:database | :view | :doc | :all_docs]",
    :examples => ["drop :database, 'test'", "drop :view, 'Riders/top_ten'", "drop :doc, '23'", "drop :all_docs"]
  }
end

Instance Method Details

#run(*params) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/couchup/commands/drop.rb', line 5

def run(*params)
  op_type = params.shift.to_s
  (params.first.nil? ? Couchup.database : Couchup.new_database(params.first.to_s)).delete! 
  ::Couchup::View.new(params.first).delete! if op_type == 'view'
  Couchup.delete_doc(params.first) if op_type == 'doc'
  Couchup.delete_all_docs(params.first) if op_type == 'all_docs'
end