Module: NetboxClientRuby::Entities::ClassMethods
- Defined in:
- lib/netbox_client_ruby/entities.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check_limit(limit) ⇒ Object
- #count_key(key = 'count') ⇒ Object
- #data_key(key = 'data') ⇒ Object
- #entity_creator(creator = nil) ⇒ Object
- #limit(limit = nil) ⇒ Object
- #path(path = nil) ⇒ Object
Class Method Details
.extended(other_klass) ⇒ Object
14 15 16 |
# File 'lib/netbox_client_ruby/entities.rb', line 14 def self.extended(other_klass) @other_klass = other_klass end |
Instance Method Details
#check_limit(limit) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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') ⇒ Object
22 23 24 |
# File 'lib/netbox_client_ruby/entities.rb', line 22 def count_key(key = 'count') @count_key ||= key end |
#data_key(key = 'data') ⇒ Object
18 19 20 |
# File 'lib/netbox_client_ruby/entities.rb', line 18 def data_key(key = 'data') @data_key ||= key end |
#entity_creator(creator = nil) ⇒ Object
61 62 63 64 65 66 67 |
# 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) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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) ⇒ Object
69 70 71 72 73 74 75 |
# 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 |