Class: Chimps::Commands::Update

Inherits:
Chimps::Command show all
Includes:
Utils::ActsOnResource, Utils::UsesParamValueData
Defined in:
lib/chimps-cli/commands/update.rb

Overview

A command to issue a PUT request to update a resource at Infochimps.

Constant Summary collapse

USAGE =
"usage: chimps update [OPTIONS] [RESOURCE] ID_OR_SLUG [PROP=VALUE] ..."
HELP =
<<EOF

Updates a #{default_resource_type} identified by the given ID or slug using the properties
 and values supplied.

#{how_to_input_data}
#{resources_listing}

Examples:

  $ chimps update my-awesome-dataset title='Yet More Awesome Dataset' description="It is even cooler"
  $ chimps update source my-source -d my_source.yml
EOF

Instance Attribute Summary

Attributes inherited from Chimps::Command

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::UsesParamValueData

#data, included

Methods included from Utils::ActsOnResource

#first_arg_is_resource_type?, #has_resource_identifier?, included, #plural_resource, #resource_identifier, #resource_path, #resource_type, #resources_path

Methods inherited from Chimps::Command

#initialize, name, #name

Constructor Details

This class inherits a constructor from Chimps::Command

Class Method Details

.allowed_modelsObject



11
12
13
# File 'lib/chimps-cli/commands/update.rb', line 11

def self.allowed_models
  %w[dataset source license]
end

Instance Method Details

#execute!Object



30
31
32
33
# File 'lib/chimps-cli/commands/update.rb', line 30

def execute!
  ensure_data_is_present!
  Request.new(resource_path, :body => {resource_type => data } , :sign => true).put.print
end