Class/Module Index [+]

Quicksearch

HammerCLIForeman::ListCommand

Public Class Methods

command_name(name=nil) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 292
def self.command_name(name=nil)
  super(name) || "list"
end

Public Instance Methods

adapter() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 274
def adapter
  @context[:adapter] || :table
end
execute() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 296
def execute
  if should_retrieve_all?
    print_data(retrieve_all)
  else
    self.option_page = (self.option_page || 1).to_i if respond_to?(:option_page)
    self.option_per_page = (self.option_per_page || HammerCLI::Settings.get(:ui, :per_page) || DEFAULT_PER_PAGE).to_i if respond_to?(:option_per_page)
    print_data(send_request)
  end

  return HammerCLI::EX_OK
end
extend_data(record) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 288
def extend_data(record)
  record
end
send_request() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 278
def send_request
  set = super
  set.map! { |r| extend_data(r) }
  set
end
transform_format(data) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 284
def transform_format(data)
  HammerCLIForeman.collection_to_common_format(data)
end

Protected Instance Methods

pagination_supported?() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 325
def pagination_supported?
  respond_to?(:option_page) && respond_to?(:option_per_page)
end
retrieve_all() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 310
def retrieve_all
  self.option_per_page = RETRIEVE_ALL_PER_PAGE
  self.option_page = 1

  d = send_request
  all = d

  while (d.size == RETRIEVE_ALL_PER_PAGE) do
    self.option_page += 1
    d = send_request
    all += d
  end
  all
end
should_retrieve_all?() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 329
def should_retrieve_all?
  pagination_supported? && option_per_page.nil? && option_page.nil?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.