module NetboxClientRuby::Entities::ClassMethods

Public Class Methods

extended(other_klass) click to toggle source
# File lib/netbox_client_ruby/entities.rb, line 14
def self.extended(other_klass)
  @other_klass = other_klass
end

Public Instance Methods

check_limit(limit) click to toggle source
# File lib/netbox_client_ruby/entities.rb, line 41
def check_limit(limit)
  max_limit = NetboxClientRuby.config.netbox.pagination.max_limit
  if limit.nil?
    raise ArgumentError,
          "'limit' can not be nil."
  elsif !limit.is_a?(Numeric)
    raise ArgumentError,
          "The limit '#{limit}' is not numeric but it has to be."
  elsif !limit.integer?
    raise ArgumentError,
          "The limit '#{limit}' is not integer but it has to be."
  elsif limit.negative?
    raise ArgumentError,
          "The limit '#{limit}' is below zero, but it should be zero or bigger."
  elsif limit > max_limit
    raise ArgumentError,
          "The limit '#{limit}' is bigger than the configured limit value ('#{max_limit}')."
  end
end
count_key(key = 'count') click to toggle source
# File lib/netbox_client_ruby/entities.rb, line 22
def count_key(key = 'count')
  @count_key ||= key
end
data_key(key = 'data') click to toggle source
# File lib/netbox_client_ruby/entities.rb, line 18
def data_key(key = 'data')
  @data_key ||= key
end
entity_creator(creator = nil) click to toggle source
# File lib/netbox_client_ruby/entities.rb, line 61
def entity_creator(creator = nil)
  return @entity_creator if @entity_creator

  raise ArgumentError, '"entity_creator" has not been defined.' unless creator

  @entity_creator = creator
end
limit(limit = nil) click to toggle source
# File lib/netbox_client_ruby/entities.rb, line 26
def limit(limit = nil)
  return @limit if @limit

  @limit = limit || NetboxClientRuby.config.netbox.pagination.default_limit

  if @limit.nil?
    raise ArgumentError,
          "Whether 'limit' nor 'default_limit' are defined."
  end

  check_limit @limit

  @limit
end
path(path = nil) click to toggle source
# File lib/netbox_client_ruby/entities.rb, line 69
def path(path = nil)
  return @path if @path

  raise ArgumentError, '"path" has not been defined.' unless path

  @path = path
end