class ThreeScaleToolbox::Commands::MethodsCommand::Delete::DeleteSubcommand

Public Class Methods

command() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 8
def self.command
  Cri::Command.define do
    name        'delete'
    usage       'delete [opts] <remote> <service> <method>'
    summary     'delete method'
    description 'Delete method'

    param       :remote
    param       :service_ref
    param       :method_ref

    runner DeleteSubcommand
  end
end

Public Instance Methods

run() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 23
def run
  method.delete
  puts "Method id: #{method.id} deleted"
end

Private Instance Methods

find_method() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 45
def find_method
  hits = service.hits
  Entities::Method.find(service: service, ref: method_ref).tap do |p|
    raise ThreeScaleToolbox::Error, "Method #{method_ref} does not exist" if p.nil?
  end
end
find_service() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 38
def find_service
  Entities::Service.find(remote: remote,
                         ref: service_ref).tap do |svc|
    raise ThreeScaleToolbox::Error, "Service #{service_ref} does not exist" if svc.nil?
  end
end
method() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 34
def method
  @method ||= find_method
end
method_ref() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 60
def method_ref
  arguments[:method_ref]
end
remote() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 52
def remote
  @remote ||= threescale_client(arguments[:remote])
end
service() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 30
def service
  @service ||= find_service
end
service_ref() click to toggle source
# File lib/3scale_toolbox/commands/methods_command/delete_command.rb, line 56
def service_ref
  arguments[:service_ref]
end